CBMR-Single-Cell-Omics-Platform / SCOPfunctions

An R package of functions for single cell -omics analysis.
GNU Affero General Public License v3.0
8 stars 7 forks source link

negative logFC missing differential_expression.R #5

Closed flde closed 1 year ago

flde commented 1 year ago

Dear all,

Many thanks for the great adaption of the MAST RE worflow! Briefly, I am calculating log2(CPM+1) values manually, put the sparese matrix in the data slot of the Seurat object, and set base=2.

My problem is that I only get results for positve log2FC but I would also be interessted in negative changes. Is that the expected behaviour of DE_MAST_RE_seurat? I tried following the code but it is not clear to me.

If you could give me a hint that would be great!

Kind regards, Florian

flde commented 1 year ago

Maybe I missunderstood the vignitte but if the data slot is log2(CPM+1) than the log2FC of the output from .FoldChange.default will always be greater 0. And the expm1 would not reverse the log2. Now I am confused...

https://github.com/CBMR-Single-Cell-Omics-Platform/SCOPfunctions/blob/b7c3656a58f6f021a0b8aa5670b48735cdbd8430/R/differential_expression.R#L155-L171

flde commented 1 year ago

I adopted your approach with my own function and it works fine. Sorry for the confusion, no posts on GitHub on Friday afternoons no more.

Many thanks for sharing the code, that is a great help!

Best wishes, Florian