Stuartlab-UCSC / traj-converters

Utilities for converting output of trajectory inference algorithms.
0 stars 0 forks source link

write_common_json produces error for monocle object #3

Closed JEFworks closed 6 years ago

JEFworks commented 6 years ago
> write_common_json(monocle_obj, file=output)
Error in which_branch(path, mst_node_to_ids, branch_assignment) : 
  The branch finding method was indeterminant.
Called from: which_branch(path, mst_node_to_ids, branch_assignment)

Debug traces back to:

function(path_vertices, mst_node_to_ids, branch_assignment) {
    # returns which branch a path maps too.
    # if this path has ALL the cell ids in a branch we assume its the branch.
    total_counts <- summary(branch_assignment)

    # get all the cells along the path.
    cell_ids_in_path <- c()
    for (node in path_vertices){
      cell_ids_in_path <- c(cell_ids_in_path, mst_node_to_ids[[node]])  
    }

    count_on_branch <- summary(branch_assignment[cell_ids_in_path])

    branch <- which(total_counts[names(count_on_branch)] == count_on_branch, arr.ind = FALSE)

    indeterminant_number_of_branches <- length(branch) != 1
    if (indeterminant_number_of_branches){
      stop("The branch finding method was indeterminant.")
    }

    return(unname(branch)[1])
  }

monocle_obj is valid output of

> monocle_obj <- monocle_analysis(exp_mat)
> monocle_obj
CellDataSet (storageMode: environment)
assayData: 500 features, 110 samples 
  element names: exprs 
protocolData: none
phenoData
  sampleNames: 1 2 ... 110 (110 total)
  varLabels: Size_Factor Pseudotime State
  varMetadata: labelDescription
featureData
  featureNames: gene1 gene2 ... gene500 (500 total)
  fvarLabels: use_for_ordering
  fvarMetadata: labelDescription
experimentData: use 'experimentData(object)'
Annotation: 
> plot_cell_trajectory(monocle_obj)

image

Session info:

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS  10.13.4

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] splines   stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] jsonlite_1.5         monocle_2.2.0        DDRTree_0.1.5        irlba_2.3.1          VGAM_1.0-3          
 [6] ggplot2_2.2.1        Biobase_2.34.0       BiocGenerics_0.20.0  Matrix_1.2-12        BiocInstaller_1.24.0
[11] ecp_3.1.0            Rcpp_0.12.14         mvtnorm_1.0-6        biomaRt_2.30.0      

loaded via a namespace (and not attached):
 [1] lattice_0.20-35        assertthat_0.2.0       rprojroot_1.2          digest_0.6.13         
 [5] slam_0.1-40            R6_2.2.2               plyr_1.8.4             backports_1.1.1       
 [9] sparsesvd_0.1-1        qlcMatrix_0.9.7        RSQLite_2.0            evaluate_0.10.1       
[13] rlang_0.1.6            lazyeval_0.2.1         blob_1.1.0             S4Vectors_0.12.2      
[17] combinat_0.0-8         rmarkdown_1.10         labeling_0.3           devtools_1.13.6       
[21] Rtsne_0.13             stringr_1.2.0          igraph_1.1.2           pheatmap_1.0.10       
[25] RCurl_1.95-4.8         bit_1.1-12             munsell_0.4.3          proxy_0.4-19          
[29] pkgconfig_2.0.1        htmltools_0.3.6        tibble_1.3.4           IRanges_2.8.2         
[33] matrixStats_0.52.2     XML_3.98-1.9           dplyr_0.7.4            withr_2.1.0           
[37] bitops_1.0-6           grid_3.3.3             gtable_0.2.0           DBI_0.7               
[41] magrittr_1.5           scales_0.5.0           docopt_0.6             stringi_1.1.6         
[45] reshape2_1.4.3         bindrcpp_0.2           limma_3.30.13          fastICA_1.2-1         
[49] RColorBrewer_1.1-2     tools_3.3.3            bit64_0.9-7            glue_1.2.0.9000       
[53] HSMMSingleCell_0.108.0 yaml_2.1.16            AnnotationDbi_1.36.2   colorspace_1.3-2      
[57] cluster_2.0.6          memoise_1.1.0          knitr_1.20             bindr_0.1             
mrJeppard commented 6 years ago

Thanks, please try again with the latest commits.

If you get the same error then please share input and/or a minimal example to recreate the error.

My apologies for the rockiness, a number of edge cases are getting cleaned up.

JEFworks commented 6 years ago

Works with latest commits!