cacoa icon indicating copy to clipboard operation
cacoa copied to clipboard

ClusterFreeExpression Not S4 object

Open jayp2919 opened this issue 3 years ago • 3 comments

Thank you for the amazing package, I was running the steps and everything was working until the differential gene analysis. Error of not an S4 object. I was not sure what the problem was as all the previous steps ran fine with the cao environment.

cao$estimateClusterFreeExpressionShifts(gene.selection="expression", min.n.between=1, min.n.within=1) Error in estimateClusterFreeExpressionShiftsC(t(cm), self$sample.per.cell[rownames(cm)], : Not an S4 object.

image

I appreciate your help and this tool!

jayp2919 avatar May 26 '22 04:05 jayp2919

@jayp2919 , What kind of data.object do you use? Is it a count matrix?

VPetukhov avatar Jun 29 '22 19:06 VPetukhov

@jayp2919

Without more commands and data to reproduce this bug, we're left guessing.

Could you share your data and the precise commands you ran here? That will help with debugging. The more you share, the better---we'll be able to reproduce the problems.

Best, Evan

evanbiederstedt avatar Jul 09 '22 23:07 evanbiederstedt

Hello I am unable to perform downstream analysis of cluster differential expression/gene programs. I am using Seurat to load into cao- created from count matrices. Everything is working until cluster free expression.

cao object: https://drive.google.com/file/d/1BFe00nZJQ-Ourpk9RdfaauuQ2zUH0aj7/view?usp=sharing

I appreciate your help

cao <- cacoa::Cacoa$new( Seurat, sample.groups= sample.groups, cell.groups= cell.groups,sample.per.cell = sample.per.cell, target.level='L', ref.level='H', graph.name='integrated_nn', n.cores=1, verbose=FALSE )

cao$plot.params <- list(size=0.1, alpha=0.1, font.size=c(2, 3)) cao$plot.theme <- cao$plot.theme + theme(legend.background=element_blank())

#Cell Loading and Expression Shift cao$estimateCellLoadings() cao$estimateExpressionShiftMagnitudes(min.cells.per.sample = 1,min.gene.frac = 0)

cao$plotCellLoadings(alpha=0.0, annotation.x=0.61, show.pvals=TRUE)

cao$plotCellGroupSizes(show.significance=TRUE, legend.position=c(1, 1))

cao$plotContrastTree()

cao$plotExpressionShiftMagnitudes(notch = FALSE)

#Cluster DE and Ontology cao$estimateDEPerCellType(independent.filtering=TRUE, test='DESeq2.Wald', verbose=FALSE, min.cell.count = 1)

cao$estimateOntology(type="GSEA", org.db=org.Hs.eg.db::org.Hs.eg.db, verbose=FALSE, n.cores=1)

#Volcano Plot pdf('L_PSO_Volcano.pdf',height=24, width=10) cao3$plotVolcano(xlim=c(-3, 3), ylim=c(0, 3.5),max.overlaps=100,widthConnectors=0.25,size=c(0.1,0.5), lf.cutoff=2, p.cutoff=0.01, color.var= 'CellFrac', sel.labels=NULL, cell.frac.cutoff=0, lab.size=1) dev.off()

#Ontology Plot cao$plotOntologyHeatmapCollapsed( name="GSEA", genes="all", n=50, clust.method="ward.D", size.range=c(1, 4))

cao$plotOntologyHeatmap( name="GSEA", genes="up", description.regex="extracellular|matrix")

#Cluster Free Density

cao$plotEmbedding(color.by='cell.groups') ggsave("cao_UMAP.TIFF",height=4, width=6, dpi=1200)

cao$estimateCellDensity(method='graph') cao$estimateDiffCellDensity(type='wilcox')

plot_grid( cao$plotEmbedding(color.by='cell.groups'), cao$plotDiffCellDensity(legend.position= 'none',type = 'subtract', lims=c(0,1),labels=TRUE), ncol=2) ggsave("cao_DiffCellDensity_graph_subtract.TIFF",height=2, width=5,dpi=1200)

#ClusterFree Differential Expression cao$estimateClusterFreeExpressionShifts(gene.selection="expression", min.n.between=1, min.n.within=1)

cao$plotClusterFreeExpressionShifts(legend.position=c(1, 0), font.size=2) ggsave("cao_ClusterFreeExpression.TIFF",height=4, width=8, dpi=1200)

#DE gene programs

cao$estimateClusterFreeDE( n.top.genes=1000, min.expr.frac=0.01, adjust.pvalues=TRUE, smooth=TRUE, verbose=TRUE )

cao$estimateGenePrograms(method="leiden", z.adj=TRUE, smooth=TRUE,resolution=1, n.pcs=100, k=30, n.cores=1, verbose=FALSE)

cao$plotGeneProgramScores( legend.position=c(0, 1), plot.na=FALSE, adj.list=theme(legend.key.width=unit(8, "pt"), legend.key.height=unit(12, "pt")) )

#Plot genes from one program:

plot_grid(plotlist=cao$plotGeneProgramGenes( program.id=4, max.genes=9, plot.na=FALSE, legend.position=c(0, 1) ), ncol=3)

jayp2919 avatar Jul 10 '22 20:07 jayp2919