neurorestore / Libra

MIT License
153 stars 25 forks source link

Design order and account batch effect #32

Closed VergaJU closed 2 months ago

VergaJU commented 2 years ago

I am running DE analysis on some single cell datasets created merging multiple samples from different studies. All the datasets are saved as Seurat objects and the meta.data have this structure:

 orig.ident nCount_RNA nFeature_RNA percent_mt
PMM_Bcell_1_TCACAAGCACGGACAA-1        PMM       1943          813   4.220278
PMM_Bcell_4_AAGGAGCCAGGTCTCG-1        PMM       1285          733   2.101167
PMM_Bcell_4_GTGGGTCAGAACAATC-1        PMM       1111          601   2.430243
PMM_BM_3_GGACAAGGTCTAGCGC-1           PMM       3502         1592   4.625928
PMM_BM_8_CACAGGCGTGTATGGG-1           PMM       3393         1757   5.097230
PMM_BM_8_TGGCGCACAACTGCGC-1           PMM       2856         1419   4.201681
                                      label             cell_type   replicate
PMM_Bcell_1_TCACAAGCACGGACAA-1  NK resident CD56dimCD16+ NK cells PMM_Bcell_1
PMM_Bcell_4_AAGGAGCCAGGTCTCG-1 NK exhausted CD56dimCD16+ NK cells PMM_Bcell_4
PMM_Bcell_4_GTGGGTCAGAACAATC-1 NK exhausted CD56dimCD16+ NK cells PMM_Bcell_4
PMM_BM_3_GGACAAGGTCTAGCGC-1     NK resident CD56dimCD16+ NK cells    PMM_BM_3
PMM_BM_8_CACAGGCGTGTATGGG-1     NK resident CD56dimCD16+ NK cells    PMM_BM_8
PMM_BM_8_TGGCGCACAACTGCGC-1    NK exhausted CD56dimCD16+ NK cells    PMM_BM_8

The columns label contains the two groups that I want to compare, cell_type as the name suggest the cell types and replicate the different samples which the cells come from.

My questions are:

Thank you for the support Jacopo

jordansquair commented 2 years ago

1) Yes you can simply set the factor levels and Libra will use that to set the reference. 2) No, we will add this in an updated version. However, you can just to Libra:::to_pseudobulk and use this in your own custom analysis with edgeR/DESeq2/limma.

VergaJU commented 2 years ago

Thank you for the answer, all clear

LiMiPo commented 1 year ago

Hi,I wanna to ask how to specify the comparison in Libra?

jordansquair commented 1 year ago

See https://github.com/neurorestore/Libra/issues/6

LiMiPo commented 1 year ago

Thanks

LiMiPo commented 1 year ago

Hello,beforeI am running DE analysis,I set data$label <- factor(data$label, levels = c("after","before")),does it mean that the comparison is before vs after ?

jordansquair commented 1 year ago

The second factor level is used as reference.

LiMiPo commented 1 year ago

Thanks so much