Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"plotGenes" plots fits but not data in "case" mode #23

Open
mchimenti opened this issue Feb 5, 2021 · 1 comment
Open

"plotGenes" plots fits but not data in "case" mode #23

mchimenti opened this issue Feb 5, 2021 · 1 comment

Comments

@mchimenti
Copy link

Hi,
I'm trying to plot the fits and data to my DE time-dependent genes. plotGenes() generates plots but does not plot the underlying count data when I call it like this:

imp_res <- runImpulseDE2(matCountData = counts.ncd.mat, dfAnnotation = metadata, scaNProc = 4)
timeplots <- plotGenes(scaNTopIDs = 10, objectImpulseDE2 = imp_res, boolCaseCtrl = FALSE, boolSimplePlot = TRUE)
timeplots[[1]]


ImpulseDE2_Rplot

I suspect there is a problem somewhere in this code block (lines 258 to 280 in https://github.com/YosefLab/ImpulseDE2/blob/master/R/srcImpulseDE2_plotGenes.R):

dfRaw <- data.frame(
                normCounts = get_matCountDataProc(
                    obj=objectImpulseDE2)[id, vecSamples]/
                    get_vecSizeFactors(obj=objectImpulseDE2)[vecSamples], 
                time = dfAnnot[vecSamples, ]$Time, 
                Batch = vecBatches, 
                condition = dfAnnot[vecSamples, ]$Condition)
            
            if (boolSimplePlot) {
                dfFit <- data.frame(
                    time = vecTimePointsFit, value = vecCaseImpulseValue, 
                    Batch = rep(vecBatchLabelsCase[1], length(vecTimePointsFit)))
                if (!is.null(vecBatchLabelsCase)) {
                    gplotGene <- ggplot() + 
                        geom_point(data = dfRaw, aes(x = time,  y = normCounts, 
                                                     shape = Batch)) + 
                        geom_line(data = dfFit, 
                                  aes(x = time, y = value, linetype = Batch))
                } else {
                    gplotGene <- ggplot() + 
                        geom_point(data = dfRaw, aes(x = time, y = normCounts)) + 
                        geom_line(data = dfFit, aes(x = time, 
                                                    y = value))
                }

The plotting gives a warning:
"Removed 40 rows containing missing values (geom_point)"

^^^ I don't know specifically what this is referring to but I suspect this is why data is not plotting.

Any suggestions would be helpful. Thanks!

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid      parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ImpulseDE2_1.8.0    Vennerable_3.0      xtable_1.8-4        gtools_3.8.1        reshape_0.8.8       RColorBrewer_1.1-2 
 [7] lattice_0.20-38     RBGL_1.60.0         graph_1.62.0        BiocGenerics_0.30.0 forcats_0.4.0       stringr_1.4.0      
[13] dplyr_1.0.2         purrr_0.3.2         readr_1.3.1         tidyr_1.0.0         tibble_3.0.4        ggplot2_3.3.2      
[19] tidyverse_1.2.1     timeSeq_1.0.4       edgeR_3.26.8        limma_3.40.6        
@mchimenti
Copy link
Author

UPDATE: I solved the problem myself with this:

timeplots <- plotGenes(scaNTopIDs = 10, objectImpulseDE2 = imp_res, boolCaseCtrl = FALSE, boolSimplePlot = TRUE)
p <- timeplots[[1]]
dat <- counts.ncd.mat["ENSMUSG00000087968",] %>% t() %>% as_tibble()  %>% gather(.,key="sample",value="counts") %>% mutate(time=as.numeric(condition_ncd))
p <- p + geom_point(data = dat, aes(x=time, y=counts))
p

ImpulseDE_update_Rplot

Still, it would be nice if you could fix the original code so I don't have to manually do this for each gene. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant