rdrr-io / rdrr-issues

rdrr.io issues
34 stars 7 forks source link

Error message with transformation = log1p #83

Closed legeinei123 closed 3 years ago

legeinei123 commented 3 years ago

Hi,

I'm getting an error message when running the following:

ce <- ClusterExperiment(heatdata, heatclus, transformation = log1p)

The error message is :

Error in .checkTransform(out) : User-supplied transformation produces error on the input data matrix: Error in .local(object, ...) : User-supplied transFun produces NA values In addition: Warning message: In transFun(object) : NaNs produced

However any(is.na(heatdata)) is FALSE and so is any(is.na(heatclus)) and when I look manually I also can't see any empty values.

When I run ce <- ClusterExperiment(heatdata, heatclus) without the transformation it doesn't give me an error message but subsequent plotting using the following doesn't produce a graph (no error message either though:

clusterExperiment::plotHeatmap(ce, visualizeData = 'transformed', cexRow = 1.5, fontsize = 15, clusterSamplesData = "orderSamplesValue")

For context: The piece of code I'm trying to run comes from https://broadinstitute.github.io/2019_scWorkshop/functional-pseudotime-analysis.html and is for finding DE genes along a pseudotime with heatmap plot. Entire script looks like this:

library(gam) library(clusterExperiment)

Y <- log2(counts(sce_sling) + 1) var1K <- names(sort(apply(Y, 1, var),decreasing = TRUE))[1:1000] Y <- Y[var1K, ] # only counts for variable genes

t <- sce_sling$slingPseudotime_1 gam.pval <- apply(Y, 1, function(z){ d <- data.frame(z=z, t=t) tmp <- gam(z ~ lo(t), data=d) p <- summary(tmp)[4][[1]][1,5] p })

topgenes <- names(sort(gam.pval, decreasing = FALSE))[1:100]

heatdata <- as.matrix(logcounts(sce_sling)[rownames(sce_sling) %in% topgenes, order(t, na.last = NA)]) heatclus <- sce_sling$clusterName[order(t, na.last = NA)] png(paste0(mydir, "heatmap_time_genes.png"), width=10, height=10, units = "in", res=200) ce <- ClusterExperiment(heatdata, heatclus, transformation = log1p) clusterExperiment::plotHeatmap(ce, visualizeData = 'transformed', cexRow = 1.5, fontsize = 15, clusterSamplesData = "orderSamplesValue") dev.off()

Please let me know what you think!

legeinei123 commented 3 years ago

Moving this issue to the right repository - apologies