Error in data.frame(z = z, t = t) : arguments imply differing number of rows: 759, 0

Hello, I am attempting to do pseudo time on RNA seq data but I am getting a data frame error. I am unsure how to fix this data frame. The code and error are below. Thank you!

require(gam)
t <- E.sce$slingPseudotime_1
# for time, only look at the 100 most variable genes
head(E.sce)
Y <- log1p(assays(E.sce)$logcounts)
var100 <- names(sort(apply(Y,1,var),decreasing = TRUE))[1:100]
Y <- Y[var100,]
# fit a GAM with a loess term for pseudotime
gam.pval <- apply(Y,1,function(z){
  d <- data.frame(z=z, t=t)
  suppressWarnings({
    tmp <- suppressWarnings(gam(z ~ lo(t), data=d))
  })
  p <- summary(tmp)[3][[1]][2,3]
  p
})


 Error in data.frame(z = z, t = t) : 
  arguments imply differing number of rows: 759, 0

Is t empty? That would explain the problem (if that column doesn't exist, t may contain NULL). Can you share the output of

head(E.sce)

Also:

it looks like you're taking the log of an already log-transformed count. Are you sure about that?

Something to consider, Do you have a reasoned argument for why z and t should be the same length?

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like

Hi AlexisW!
T is not empty.
Here is the output for head(E.sce):

class: SingleCellExperiment 
dim: 6 759 
metadata(0):
assays(2): counts logcounts
rownames(6): Xkr4 Rp1 ... Lypla1 Gm37988
rowData names(5): vst.mean vst.variance vst.variance.expected vst.variance.standardized vst.variable
colnames(759): AAAGGATAGAGTCTTC-1 AACGGGAGTGTCCGGT-1 ... TTTATGCCATGGCCCA-3 TTTCCTCTCTGGCCAG-3
colData names(9): orig.ident nCount_RNA ... RNA_snn_res.1.2 ident
reducedDimNames(2): PCA UMAP
altExpNames(0):