lhe17 / nebula

GNU General Public License v2.0
26 stars 6 forks source link

Co-expression code #23

Open AbhijeetRPatil opened 1 year ago

AbhijeetRPatil commented 1 year ago

Hi, Thanks for developing this awesome package for measuring differential expression analysis in scRNA-seq through mixed modelling! In the manuscript, I saw the co-expression analysis. Can you please let me know where I can find the relevant code in the package. Thanks for your help!

lhe17 commented 1 year ago

Hi Abhijeet R Patil,

Thank you for your question.

To investigate co-expression of Gene A with other genes, we include normalized expression of Gene A in the design matrix. You could include only those genes of which you want to investigate the co-expression in the count matrix. To illustrate, I give an example script below for the co-expression analysis of APOE in the paper using a Seurat Object.

covs = @.**    # pbmc is a Seurat Object of the single-cell data set covs$apoe_e = counts[match('APOE',rownames(counts)),]/as.numeric(as.character(covs$nCount_RNA))1e3

get expression of APOE normalized by library size. If the gene has

many zeros, you might use other normalized methods such as Pearson residuals which can be obtained from NEBULA apoe_m = aggregate(apoe_e~orig.ident,covs,mean)    # get subject-level mean of the expression of APOE covs$apoe_e_c = covs$apoe_e - apoe_m[match(covs$orig.ident,apoe_m[,1]),2]    # subtract subject-level mean from normalized expression (This step is optional, depending on whether you want cell-level co-exp only.) pred = model.matrix(~nFeature_RNA+rprot+percent.mt+apoe_e_c,covs)    # create a design matrix, adjusting for covariates like number of non-zero features, ribosomal and mitochondria mrna percentage id = as.numeric(factor(as.character(covs$ind),levels=unique(as.character(covs$ind)))) re = nebula(counts,id,pred=pred,offset=covs$nCount_RNA)    # the logFC and p-value of apoe_e_c give information about the co-expression between APOE and all genes in the count matrix @.**@.'

Best regards,

Liang

On 5/10/2023 5:56 PM, ABHIJEET R PATIL wrote:

Hi, Thanks for developing this awesome package for measuring differential expression analysis in scRNA-seq through mixed modelling! In the manuscript, I saw the co-expression analysis. Can you please let me know where I can find the relevant code in the package. Thanks for your help!

— Reply to this email directly, view it on GitHub https://github.com/lhe17/nebula/issues/23, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGDISUWBTRJPTF7AND3QKQLXFO3ERANCNFSM6AAAAAAX4525CE. You are receiving this because you are subscribed to this thread.Message ID: @.***>