Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), : 'data' must be of a vector type, was 'NULL' #113

@zimmermk1986

Description

@zimmermk1986

I am attempting to "Analyzing Branches in Single-Cell Trajectories" using a Seurat 3 object imported into monocle 2. I have made it through the entire tutorial successfully until I try to analyze the branches in single cell trajectories using the code below. When I try to do the command plot_genes_branched_heatmap I get the following error. How do I fix this?

Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
'data' must be of a vector type, was 'NULL'

data <- as(as.matrix(res@assays$RNA@data), 'sparseMatrix')
pd <- new('AnnotatedDataFrame', data = res@meta.data)
fData <- data.frame(gene_short_name = row.names(data), row.names = row.names(data))
fd <- new('AnnotatedDataFrame', data = fData)
cds <- newCellDataSet(data, phenoData = pd, featureData = fd, lowerDetectionLimit = 0.5, expressionFamily = negbinomial.size())
cds <- estimateSizeFactors(cds)
cds <- estimateDispersions(cds)
Removing 410 outliers
There were 50 or more warnings (use warnings() to see the first 50)
cds <- detectGenes(cds, min_expr = 0.1)
print(head(fData(cds)))
gene_short_name use_for_ordering num_cells_expressed
Mrpl15 Mrpl15 FALSE 149
Lypla1 Lypla1 FALSE 41
Tcea1 Tcea1 FALSE 119
Atp6v1h Atp6v1h FALSE 84
Rb1cc1 Rb1cc1 FALSE 65
4732440D04Rik 4732440D04Rik FALSE 33
expressed_genes <- row.names(subset(fData(cds), num_cells_expressed >= 10))
disp_table <- dispersionTable(cds)
unsup_clustering_genes <- subset(disp_table, mean_expression >= 0.1)
cds <- setOrderingFilter(cds, unsup_clustering_genes$gene_id)
plot_ordering_genes(cds)
Warning messages:
1: Transformation introduced infinite values in continuous y-axis
2: Transformation introduced infinite values in continuous y-axis
cds <- reduceDimension(cds, max_components = 2, num_dim = 6, reduction_method = 'tSNE', verbose = T)
Remove noise by PCA ...
Reduce dimension by tSNE ...

marker_genes <- row.names(subset(fData(cds),

  •                              gene_short_name %in% c("Cd63", "C1qa", "Ccr2",
    
  •                                                     "Apoe", "Sepp1","Pf4",
    
  •                                                     "Napsa",  "Clec12a",  "Fos",
    
  •                                                     "Junb",  "Dusp1")))
    

diff_test_res <- differentialGeneTest(cds[marker_genes,])
sig_genes <- subset(diff_test_res, qval < 0.1)
sig_genes[,c("gene_short_name", "pval", "qval")]
gene_short_name pval qval
C1qa C1qa 1.013719e-12 3.716969e-12
Pf4 Pf4 5.704000e-05 6.971555e-05
Clec12a Clec12a 9.993933e-12 2.748332e-11
Apoe Apoe 2.208108e-29 2.428918e-28
Napsa Napsa 1.403176e-06 2.204990e-06
Cd63 Cd63 2.004831e-04 2.004831e-04
Junb Junb 1.131497e-05 1.555808e-05
Ccr2 Ccr2 3.641001e-07 6.675169e-07
Fos Fos 4.840100e-15 2.662055e-14
Sepp1 Sepp1 4.030497e-09 8.867094e-09
Dusp1 Dusp1 7.190949e-05 7.910044e-05
MYOG_ID1 <- cds[row.names(subset(fData(cds), gene_short_name %in% c("C1qa", "Apoe"))),]
plot_genes_jitter(MYOG_ID1, grouping = "seurat_clusters", ncol= 2)
to_be_tested <- row.names(subset(fData(cds), gene_short_name %in% c("Apoe", "Fos", "C1qa")))
cds_subset <- cds[to_be_tested,]
diff_test_res <- differentialGeneTest(cds_subset)
diff_test_res[,c("gene_short_name", "pval", "qval")]
gene_short_name pval qval
C1qa C1qa 1.013719e-12 1.013719e-12
Apoe Apoe 2.208108e-29 6.624323e-29
Fos Fos 4.840100e-15 7.260150e-15
plot_genes_jitter(cds_subset,

  •               grouping = "seurat_clusters",
    
  •               color_by = "seurat_clusters",
    
  •               nrow= 1,
    
  •               ncol = NULL,
    
  •               plot_trend = TRUE)
    

Warning messages:
1: Computation failed in stat_summary():
Hmisc package required for this function
2: Computation failed in stat_summary():
Hmisc package required for this function
3: Computation failed in stat_summary():
Hmisc package required for this function
4: Computation failed in stat_summary():
Hmisc package required for this function
5: Computation failed in stat_summary():
Hmisc package required for this function
6: Computation failed in stat_summary():
Hmisc package required for this function

to_be_tested <- row.names(subset(fData(cds), gene_short_name %in% c("Apoe", "C1qa", "Fos")))
cds_subset <- cds[to_be_tested,]
diff_test_res <- differentialGeneTest(cds_subset, fullModelFormulaStr = "~sm.ns(Pseudotime)")
diff_test_res[,c("gene_short_name", "pval", "qval")]
gene_short_name pval qval
C1qa C1qa 2.145791e-08 2.145791e-08
Apoe Apoe 5.811938e-23 1.743581e-22
Fos Fos 2.683403e-16 4.025104e-16
plot_genes_in_pseudotime(cds_subset, color_by = "seurat_clusters")
diff_test_res <- differentialGeneTest(cds[marker_genes,], fullModelFormulaStr = "~sm.ns(Pseudotime)")
sig_gene_names <- row.names(subset(diff_test_res, qval < 0.1))
plot_pseudotime_heatmap(cds[sig_gene_names,],

  •                     num_clusters = 3,
    
  •                     cores = 1,
    
  •                     show_rownames = T)
    

plot_cell_trajectory(cds, color_by = "Pseudotime")
plot_cell_trajectory(cds, color_by = "seurat_clusters")
BEAM_res <- BEAM(cds, branch_point = 2, cores = 1)
Warning messages:
1: In if (progenitor_method == "duplicate") { :
the condition has length > 1 and only the first element will be used
2: In if (progenitor_method == "sequential_split") { :
the condition has length > 1 and only the first element will be used
BEAM_res <- BEAM_res[order(BEAM_res$qval),]
BEAM_res <- BEAM_res[,c("gene_short_name", "pval", "qval")]
plot_genes_branched_heatmap(cds[row.names(subset(BEAM_res,

  •                                               qval < 1e-4)),],
    
  •                         branch_point = 2,
    
  •                         num_clusters = 4,
    
  •                         cores = 1,
    
  •                         use_gene_short_name = T,
    
  •                         show_rownames = T)
    

Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
'data' must be of a vector type, was 'NULL'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions