Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obtain per-sample expression value for a gene set #137

Open
PatrickMaclean opened this issue Jul 12, 2023 · 1 comment
Open

Obtain per-sample expression value for a gene set #137

PatrickMaclean opened this issue Jul 12, 2023 · 1 comment

Comments

@PatrickMaclean
Copy link

PatrickMaclean commented Jul 12, 2023

Hi - thank you for your great work on the package.

I'm sorry if I've overlooked something obvious, but how do I extract the per-sample scores for each geneset obtained through geseca?

I can run geseca with:
gesecaRes <- geseca(pathways, E, minSize = 15, maxSize = 500)

and then plot the per-sample expression value for a specified geneset with:
plotCoregulationProfile(pathway=pathways[["SANA_TNF_SIGNALING_UP"]], E=E, titles = metadata$aample, conditions = metadata$cohort)

How do I just obtain the data used by plotCoregulationProfile (sample x expression value for a specified gene set) so I can plot it more flexibly?

Thanks!

@PatrickMaclean PatrickMaclean changed the title Obtain per-sample Obtain per-sample expression value for a gene set Jul 12, 2023
@vdsukhov
Copy link
Member

@PatrickMaclean Hi

You could try to adapt the code that we are using inside of plotCoregulationProfile:

conditions <- # your conditions here or NULL
E <- t(base::scale(t(E), center=center, scale = scale))

genes <- pathway


if (!is.null(conditions)) {
    if (is.character(conditions)) {
        conditions <- factor(conditions, levels=unique(conditions))
    }
}

pointDt <- data.table(x = seq_len(ncol(E)),
                        y = colSums(E[rownames(E) %in% genes, , drop=FALSE]) / sum(rownames(E) %in% genes),
                        condition=if (!is.null(conditions)) { conditions  } else "x")

If you want to obtain information about the behavior of each gene in a gene set, take a look at how we handle it here

Let me know if something is unclear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants