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

Multiple factor experiments (non-binary). #28

Open
grabearummc opened this issue Sep 1, 2020 · 6 comments
Open

Multiple factor experiments (non-binary). #28

grabearummc opened this issue Sep 1, 2020 · 6 comments

Comments

@grabearummc
Copy link

What if I have a multi-factor experiment with more than 2 conditions? How can I use EnrichmentBrowser?

> design <- model.matrix(~ 0+factor(c(1,1,1,2,2,3,3,3,4,4,4,5,5,5,6,6,6)))
> colnames(design) <- c("group1", "group2", "group3", "group4", "group5", "group6")
> contrast.matrix <- makeContrasts((group2+group3)-(group4+group5), levels=design)
> fit2 <- contrasts.fit(fit, contrast.matrix)
> fit2 <- eBayes(fit2)            
> design
   group1 group2 group3 group4 group5 group6
1       1      0      0      0      0      0
2       1      0      0      0      0      0
3       1      0      0      0      0      0
4       0      1      0      0      0      0
5       0      1      0      0      0      0
6       0      0      1      0      0      0
7       0      0      1      0      0      0
8       0      0      1      0      0      0
9       0      0      0      1      0      0
10      0      0      0      1      0      0
11      0      0      0      1      0      0
12      0      0      0      0      1      0
13      0      0      0      0      1      0
14      0      0      0      0      1      0
15      0      0      0      0      0      1
16      0      0      0      0      0      1
17      0      0      0      0      0      1
attr(,"assign")
[1] 1 1 1 1 1 1
attr(,"contrasts")
attr(,"contrasts")$`factor(c(1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6))`
[1] "contr.treatment"

> contrast.matrix
        Contrasts
Levels   (group2 + group3) - (group4 + group5)
  group1                                     0
  group2                                     1
  group3                                     1
  group4                                    -1
  group5                                    -1
  group6        
@grabearummc
Copy link
Author

grabearummc commented Sep 1, 2020

Let's say I've already done the differential gene expression analysis. How can I continue with EnrichmentBrowser::import/sbea/nbea?

@lgeistlinger
Copy link
Owner

Question 1: Most GSA methods only support two groups comparisons. That means, you'll need to break down multi-group comparisons into the atomic unit of several 2-group comparisons.

Question 2: let's say you would like to do a GO enrichment analysis with your results from limma (assuming you have human data):

se <- import(el, res)
go.gs <- getGenesets(org = "hsa", db = "go", onto = "BP")
sbea.res <- sbea("ora", se, go.gs, perm = 0)
gsRanking(sbea.res, signif.only = FALSE)

@lgeistlinger
Copy link
Owner

lgeistlinger commented Sep 1, 2020

I think import would then need to allow to specify which two groups you would like to compare / for which DE results should be imported. Good point.

@grabearummc
Copy link
Author

grabearummc commented Sep 1, 2020

I think import would then need to allow to specify which two groups you would like to compare / for which DE results should be imported. Good point.

Nice! I was thinking this through earlier, and that crossed my mind, but I wasn't 100% sure if that was the right thing to do. So should I filter out samples based on my intended comparison? So (using my example) should I remove group1 and group6 and then combine everything else?

@lgeistlinger
Copy link
Owner

Exactly. This is how you could produce an index vector that allows you to subset to the relevant samples for comparison (would make samples in groups 2 and 3 your reference group, ie group 0; change accordingly if you want samples in groups 4 and 5 to be the reference).

group <- c(1,1,1,2,2,3,3,3,4,4,4,5,5,5,6,6,6)
group[group %in% 2:3] <- 0
group[group %in% 4:5] <- 1
rel.samples <- group %in% 0:1

@grabearummc
Copy link
Author

Good deal. Much appreciated @lgeistlinger!

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

No branches or pull requests

2 participants