const-ae / glmGamPoi

Fit Gamma-Poisson Generalized Linear Models Reliably
105 stars 14 forks source link

Regression analysis to produce DEGs #20

Closed Al-Murphy closed 3 years ago

Al-Murphy commented 3 years ago

Hi,

I am hoping to use glmGamPoi to identify differentially expressed genes (DEGs) across differing cell types from a linear regression analysis (where Y is continuous rather than discrete). I have come up with the following approach and just want to validate it with you as I couldn't find a linear regression analysis example in the documentation. Note I have been using an approach for this question where Y is discrete (disease vs control cases) which has been working great and just want to verify my approach for linear rather than logistic regression.

First, imagine a dataset with the following columns:

So we would build the model (fit) as follows, note I leave reference_level as NULL as I would usually set this to Control in a disease control comparison so since this is regression, I assumed this was the correct approach. Can you confirm?:

fit <- glmGamPoi::glm_gp(datset, 
                           design = ~ celltype:sex + celltype:Y -1,
                           reference_level = NULL) 

Then I would identify DEGs per cell type as follows (running for each cell type):

de_res <- glmGamPoi::test_de(fit, contrast = celltype_i, 
                                 pseudobulk_by = paste0(patient_ID,"-",celltype),
                                 pval_adjust_method = "BH")