├── src ├── Makevars ├── .gitignore ├── docker │ └── NOTES ├── RcppExports.cpp └── clustering.cpp ├── vignettes ├── .gitignore ├── whbiocvignette.sty └── monocle3-vignette.Rnw ├── LICENSE ├── inst ├── extdata │ ├── matrix.mtx.gz │ ├── lung_exprs_data.RData │ ├── lung_feature_data.RData │ ├── lung_phenotype_data.RData │ ├── small_a549_dex_exprs.rda │ ├── small_a549_dex_fdata.rda │ ├── small_a549_dex_pdata.rda │ ├── worm_l2 │ │ ├── worm_l2_coldata.rds │ │ ├── worm_l2_rowdata.rds │ │ ├── worm_l2_expression_matrix.rds │ │ └── NOTES │ ├── worm_embryo │ │ ├── worm_embryo_coldata.rds │ │ ├── worm_embryo_rowdata.rds │ │ ├── worm_embryo_expression_matrix.rds │ │ └── NOTES │ ├── barcodes_c2h0.txt │ ├── cell_ranger_3 │ │ └── outs │ │ │ └── filtered_feature_bc_matrix │ │ │ ├── matrix.mtx.gz │ │ │ ├── barcodes.tsv.gz │ │ │ └── features.tsv.gz │ └── features_c3h0.txt ├── WORDLIST ├── louvain.py └── CITATION ├── .gitignore ├── tests ├── testdata │ ├── MatrixMarket │ │ ├── matrix.mtx.gz │ │ ├── features_c1h0.txt │ │ ├── barcodes_c1h0.txt │ │ ├── features_c1h1.txt │ │ ├── barcodes_c1h1.txt │ │ ├── features_c2h1.txt │ │ ├── barcodes_c3h0.txt │ │ ├── barcodes_c3h2.txt │ │ ├── barcodes_c3h3.txt │ │ ├── features_c3h0.txt │ │ ├── features_c3h2.txt │ │ ├── features_c3h2q.txt │ │ └── features_c3h3.txt │ ├── cr3.0 │ │ └── outs │ │ │ └── filtered_feature_bc_matrix │ │ │ ├── barcodes.tsv.gz │ │ │ ├── features.tsv.gz │ │ │ └── matrix.mtx.gz │ └── cr2.0 │ │ └── outs │ │ └── filtered_gene_bc_matrices │ │ └── hg19 │ │ └── barcodes.tsv ├── spelling.R ├── testthat.R └── testthat │ ├── test-zzz.R │ ├── test-find_markers.R │ ├── test-compare_models.R │ ├── test-cluster_genes.R │ ├── test-utils.R │ ├── test-select_cells.R │ ├── test-cell_data_set.R │ ├── test-evaluate_models.R │ └── test-load_cellranger_data.R ├── .github ├── CODEOWNERS └── ISSUE_TEMPLATE │ └── bug_report.md ├── man ├── cell_data_set-methods.Rd ├── pData-cell_data_set-method.Rd ├── exprs-cell_data_set-method.Rd ├── exprs.Rd ├── pData.Rd ├── fData.Rd ├── clear_cds_slots.Rd ├── principal_graph-cell_data_set-method.Rd ├── fData-set-cell_data_set-method.Rd ├── size_factors-set.Rd ├── counts_row_order-cell_data_set-method.Rd ├── fData-cell_data_set-method.Rd ├── size_factors.Rd ├── fData-set.Rd ├── pData-set.Rd ├── clusters-cell_data_set-method.Rd ├── get_citations.Rd ├── principal_graph_aux-cell_data_set-method.Rd ├── partitions-cell_data_set-method.Rd ├── pseudotime-cell_data_set-method.Rd ├── soft_assignment.Rd ├── repmat.Rd ├── counts_row_order.Rd ├── pData-set-cell_data_set-method.Rd ├── load_worm_l2.Rd ├── get_genome_in_matrix_path.Rd ├── load_worm_embryo.Rd ├── load_a549.Rd ├── model_predictions.Rd ├── generate_centers.Rd ├── align_transform.Rd ├── plot_mito_umi_per_cell.Rd ├── detect_genes.Rd ├── choose_cells.Rd ├── compare_models.Rd ├── plot_umi_per_cell.Rd ├── cell_data_set.Rd ├── make_nn_index.Rd ├── convert_counts_matrix.Rd ├── normalized_counts.Rd ├── load_monocle_objects.Rd ├── set_cds_nn_index.Rd ├── estimate_size_factors.Rd ├── plot_pc_variance_explained.Rd ├── generate_garnett_marker_file.Rd ├── plot_umi_per_cell_and_perturbation.Rd ├── calc_principal_graph.Rd ├── load_transform_models.Rd ├── load_mtx_data.Rd ├── mc_es_apply.Rd ├── set_cds_row_order_matrix.Rd ├── search_nn_matrix.Rd ├── clusters.Rd ├── choose_graph_segments.Rd ├── partitions.Rd ├── make_cds_nn_index.Rd ├── plot_cells_per_sample_and_perturbation.Rd ├── principal_graph.Rd ├── principal_graph_aux.Rd ├── pseudotime.Rd ├── principal_graph-set.Rd ├── new_cell_data_set.Rd ├── search_nn_index.Rd ├── principal_graph-set-cell_data_set-method.Rd ├── principal_graph_aux-set.Rd ├── evaluate_fits.Rd ├── principal_graph_aux-set-cell_data_set-method.Rd ├── plot_genes_in_pseudotime.Rd ├── coefficient_table.Rd ├── plot_genes_violin.Rd ├── search_cds_nn_index.Rd ├── combine_cds.Rd ├── plot_cells_3d.Rd ├── plot_genes_hybrid.Rd ├── reduce_dimension_transform.Rd ├── plot_percent_cells_positive.Rd ├── identity_table.Rd ├── load_cellranger_data.Rd ├── plot_genes_by_group.Rd ├── order_cells.Rd ├── save_transform_models.Rd ├── preprocess_transform.Rd ├── fit_models.Rd ├── set_matrix_control.Rd ├── preprocess_cds.Rd ├── sparse_prcomp_irlba.Rd └── bpcells_prcomp_irlba.Rd ├── R ├── RcppExports.R └── methods-cell_data_set.R ├── monocle3.Rproj ├── testing └── notes.todo.20230425.txt ├── LICENSE.md ├── .Rbuildignore ├── 00travis.yml ├── code-of-conduct.md ├── DESCRIPTION └── NAMESPACE /src/Makevars: -------------------------------------------------------------------------------- 1 | CXX_STD = CXX11 2 | 3 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.dll 4 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2019 2 | COPYRIGHT HOLDER: Cole Trapnell 3 | -------------------------------------------------------------------------------- /inst/extdata/matrix.mtx.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/matrix.mtx.gz -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | inst/doc 2 | .Rproj.user 3 | .Rhistory 4 | .RData 5 | .Ruserdata 6 | .DS_store 7 | .httr-oauth 8 | ^save_old.1$ 9 | -------------------------------------------------------------------------------- /inst/extdata/lung_exprs_data.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/lung_exprs_data.RData -------------------------------------------------------------------------------- /inst/extdata/lung_feature_data.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/lung_feature_data.RData -------------------------------------------------------------------------------- /inst/extdata/lung_phenotype_data.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/lung_phenotype_data.RData -------------------------------------------------------------------------------- /inst/extdata/small_a549_dex_exprs.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/small_a549_dex_exprs.rda -------------------------------------------------------------------------------- /inst/extdata/small_a549_dex_fdata.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/small_a549_dex_fdata.rda -------------------------------------------------------------------------------- /inst/extdata/small_a549_dex_pdata.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/small_a549_dex_pdata.rda -------------------------------------------------------------------------------- /inst/extdata/worm_l2/worm_l2_coldata.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/worm_l2/worm_l2_coldata.rds -------------------------------------------------------------------------------- /inst/extdata/worm_l2/worm_l2_rowdata.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/worm_l2/worm_l2_rowdata.rds -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/matrix.mtx.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/tests/testdata/MatrixMarket/matrix.mtx.gz -------------------------------------------------------------------------------- /inst/extdata/worm_embryo/worm_embryo_coldata.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/worm_embryo/worm_embryo_coldata.rds -------------------------------------------------------------------------------- /inst/extdata/worm_embryo/worm_embryo_rowdata.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/worm_embryo/worm_embryo_rowdata.rds -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/features_c1h0.txt: -------------------------------------------------------------------------------- 1 | ENSG00000243485 2 | ENSG00000237613 3 | ENSG00000268674 4 | CD3_GCCTGACTAGATCCA 5 | CD19_CGTGCAACACTCGTA 6 | -------------------------------------------------------------------------------- /inst/extdata/worm_l2/worm_l2_expression_matrix.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/worm_l2/worm_l2_expression_matrix.rds -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/barcodes_c1h0.txt: -------------------------------------------------------------------------------- 1 | AAAGTAGCACAGTCGC-1 2 | AAATGCCCACCCAGTG-1 3 | AACCGCGCAGGCGATA-1 4 | AACTCAGAGAACTCGG-1 5 | AATCCAGCAGTAACGG-1 6 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | /.github/CODEOWNERS @ctrapnell @hpliner @brgew 2 | /.github/workflows/* @ctrapnell @hpliner @brgew 3 | /src/docker/* @ctrapnell @hpliner @brgew 4 | -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/features_c1h1.txt: -------------------------------------------------------------------------------- 1 | gene_id 2 | ENSG00000243485 3 | ENSG00000237613 4 | ENSG00000268674 5 | CD3_GCCTGACTAGATCCA 6 | CD19_CGTGCAACACTCGTA 7 | -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/barcodes_c1h1.txt: -------------------------------------------------------------------------------- 1 | cell 2 | AAAGTAGCACAGTCGC-1 3 | AAATGCCCACCCAGTG-1 4 | AACCGCGCAGGCGATA-1 5 | AACTCAGAGAACTCGG-1 6 | AATCCAGCAGTAACGG-1 7 | -------------------------------------------------------------------------------- /inst/extdata/barcodes_c2h0.txt: -------------------------------------------------------------------------------- 1 | AAAGTAGCACAGTCGC-1 cell1 2 | AAATGCCCACCCAGTG-1 cell2 3 | AACCGCGCAGGCGATA-1 cell3 4 | AACTCAGAGAACTCGG-1 cell4 5 | AATCCAGCAGTAACGG-1 cell5 6 | -------------------------------------------------------------------------------- /inst/extdata/worm_embryo/worm_embryo_expression_matrix.rds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/worm_embryo/worm_embryo_expression_matrix.rds -------------------------------------------------------------------------------- /tests/spelling.R: -------------------------------------------------------------------------------- 1 | if(requireNamespace('spelling', quietly = TRUE)) 2 | spelling::spell_check_test(vignettes = TRUE, error = FALSE, 3 | skip_on_cran = TRUE) 4 | -------------------------------------------------------------------------------- /tests/testdata/cr3.0/outs/filtered_feature_bc_matrix/barcodes.tsv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/tests/testdata/cr3.0/outs/filtered_feature_bc_matrix/barcodes.tsv.gz -------------------------------------------------------------------------------- /tests/testdata/cr3.0/outs/filtered_feature_bc_matrix/features.tsv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/tests/testdata/cr3.0/outs/filtered_feature_bc_matrix/features.tsv.gz -------------------------------------------------------------------------------- /tests/testdata/cr3.0/outs/filtered_feature_bc_matrix/matrix.mtx.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/tests/testdata/cr3.0/outs/filtered_feature_bc_matrix/matrix.mtx.gz -------------------------------------------------------------------------------- /inst/extdata/cell_ranger_3/outs/filtered_feature_bc_matrix/matrix.mtx.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/cell_ranger_3/outs/filtered_feature_bc_matrix/matrix.mtx.gz -------------------------------------------------------------------------------- /inst/extdata/cell_ranger_3/outs/filtered_feature_bc_matrix/barcodes.tsv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/cell_ranger_3/outs/filtered_feature_bc_matrix/barcodes.tsv.gz -------------------------------------------------------------------------------- /inst/extdata/cell_ranger_3/outs/filtered_feature_bc_matrix/features.tsv.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cole-trapnell-lab/monocle3/HEAD/inst/extdata/cell_ranger_3/outs/filtered_feature_bc_matrix/features.tsv.gz -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/features_c2h1.txt: -------------------------------------------------------------------------------- 1 | gene_short_name 2 | ENSG00000243485 RP11-34P13.3 3 | ENSG00000237613 FAM138A 4 | ENSG00000268674 FAM231B 5 | CD3_GCCTGACTAGATCCA CD3 6 | CD19_CGTGCAACACTCGTA CD19 7 | -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/barcodes_c3h0.txt: -------------------------------------------------------------------------------- 1 | AAAGTAGCACAGTCGC-1 cell1 umi=10 2 | AAATGCCCACCCAGTG-1 cell2 umi=11 3 | AACCGCGCAGGCGATA-1 cell3 umi=12 4 | AACTCAGAGAACTCGG-1 cell4 umi=13 5 | AATCCAGCAGTAACGG-1 cell5 umi=14 6 | -------------------------------------------------------------------------------- /inst/extdata/features_c3h0.txt: -------------------------------------------------------------------------------- 1 | ENSG00000243485 RP11-34P13.3 lncRNA 2 | ENSG00000237613 FAM138A lncRNA 3 | ENSG00000268674 FAM231B protein_coding 4 | ENSG00000133048 ACHI3L1 protein_coding 5 | ENSG00000165626 BEND7 protein_coding 6 | -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/barcodes_c3h2.txt: -------------------------------------------------------------------------------- 1 | cell_number umi_token 2 | AAAGTAGCACAGTCGC-1 cell1 umi=10 3 | AAATGCCCACCCAGTG-1 cell2 umi=11 4 | AACCGCGCAGGCGATA-1 cell3 umi=12 5 | AACTCAGAGAACTCGG-1 cell4 umi=13 6 | AATCCAGCAGTAACGG-1 cell5 umi=14 7 | -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/barcodes_c3h3.txt: -------------------------------------------------------------------------------- 1 | cell cell_number umi_token 2 | AAAGTAGCACAGTCGC-1 cell1 umi=10 3 | AAATGCCCACCCAGTG-1 cell2 umi=11 4 | AACCGCGCAGGCGATA-1 cell3 umi=12 5 | AACTCAGAGAACTCGG-1 cell4 umi=13 6 | AATCCAGCAGTAACGG-1 cell5 umi=14 7 | -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/features_c3h0.txt: -------------------------------------------------------------------------------- 1 | ENSG00000243485 RP11-34P13.3 Gene_Expression 2 | ENSG00000237613 FAM138A Gene_Expression 3 | ENSG00000268674 FAM231B Gene_Expression 4 | CD3_GCCTGACTAGATCCA CD3 Antibody_Capture 5 | CD19_CGTGCAACACTCGTA CD19 Antibody_Capture 6 | -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/features_c3h2.txt: -------------------------------------------------------------------------------- 1 | gene_short_name source 2 | ENSG00000243485 RP11-34P13.3 Gene_Expression 3 | ENSG00000237613 FAM138A Gene_Expression 4 | ENSG00000268674 FAM231B Gene_Expression 5 | CD3_GCCTGACTAGATCCA CD3 Antibody_Capture 6 | CD19_CGTGCAACACTCGTA CD19 Antibody_Capture 7 | -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/features_c3h2q.txt: -------------------------------------------------------------------------------- 1 | gene_short_name source 2 | ENSG00000243485 RP1'1-34P13.3 Gene_Expression 3 | ENSG00000237613 FAM'138A Gene_Expression 4 | ENSG00000268674 FAM'231B Gene_Expression 5 | CD3_GCCTGACTAGATCCA CD3 Antibody_Capture 6 | CD19_CGTGCAACACTCGTA CD19 Antibody_Capture 7 | -------------------------------------------------------------------------------- /tests/testdata/MatrixMarket/features_c3h3.txt: -------------------------------------------------------------------------------- 1 | gene_id gene_short_name source 2 | ENSG00000243485 RP11-34P13.3 Gene_Expression 3 | ENSG00000237613 FAM138A Gene_Expression 4 | ENSG00000268674 FAM231B Gene_Expression 5 | CD3_GCCTGACTAGATCCA CD3 Antibody_Capture 6 | CD19_CGTGCAACACTCGTA CD19 Antibody_Capture 7 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(monocle3) 3 | 4 | # Prevent flashing text on some Linux platforms. 5 | options(testthat..use_colours = FALSE) 6 | # Run to end of tests. 7 | options(testthat.progress.max_fails=1000000) 8 | Sys.setenv('TESTTHAT_MAX_FAILS' = Inf) 9 | 10 | test_check("monocle3") 11 | 12 | -------------------------------------------------------------------------------- /man/cell_data_set-methods.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods-cell_data_set.R 3 | \docType{methods} 4 | \name{cell_data_set-methods} 5 | \alias{cell_data_set-methods} 6 | \title{Methods for the cell_data_set class} 7 | \arguments{ 8 | \item{object}{The cell_data_set object} 9 | } 10 | \description{ 11 | Methods for the cell_data_set class 12 | } 13 | -------------------------------------------------------------------------------- /tests/testthat/test-zzz.R: -------------------------------------------------------------------------------- 1 | context("test-zzz") 2 | 3 | test_that("get and set global variables strings", { 4 | expect_true(is.na(get_global_variable('regression_test_variable'))) 5 | expect_message(get_global_variable('regression_test_variable')) 6 | 7 | expect_silent(set_global_variable('regression_test_variable', 5)) 8 | expect_equal(get_global_variable('regression_test_variable'), 5) 9 | } ) 10 | 11 | -------------------------------------------------------------------------------- /R/RcppExports.R: -------------------------------------------------------------------------------- 1 | # Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | jaccard_coeff <- function(R_idx, R_weight) { 5 | .Call(`_monocle3_jaccard_coeff`, R_idx, R_weight) 6 | } 7 | 8 | pnorm_over_mat <- function(R_num_links_ij, R_var_null_num_links) { 9 | .Call(`_monocle3_pnorm_over_mat`, R_num_links_ij, R_var_null_num_links) 10 | } 11 | 12 | -------------------------------------------------------------------------------- /man/pData-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{pData,cell_data_set-method} 4 | \alias{pData,cell_data_set-method} 5 | \title{Method to access cds colData table} 6 | \usage{ 7 | \S4method{pData}{cell_data_set}(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | colData. 14 | } 15 | \description{ 16 | Method to access cds colData table 17 | } 18 | -------------------------------------------------------------------------------- /man/exprs-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{exprs,cell_data_set-method} 4 | \alias{exprs,cell_data_set-method} 5 | \title{Method to access cds count matrix} 6 | \usage{ 7 | \S4method{exprs}{cell_data_set}(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | Count matrix. 14 | } 15 | \description{ 16 | Method to access cds count matrix 17 | } 18 | -------------------------------------------------------------------------------- /monocle3.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | PackageRoxygenize: rd,collate,namespace 21 | -------------------------------------------------------------------------------- /man/exprs.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{exprs} 4 | \alias{exprs} 5 | \title{Generic to access cds count matrix} 6 | \usage{ 7 | exprs(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | Count matrix. 14 | } 15 | \description{ 16 | Generic to access cds count matrix 17 | } 18 | \examples{ 19 | \donttest{ 20 | cds <- load_a549() 21 | exprs(cds) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /man/pData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{pData} 4 | \alias{pData} 5 | \title{Generic to access cds colData table} 6 | \usage{ 7 | pData(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | colData. 14 | } 15 | \description{ 16 | Generic to access cds colData table 17 | } 18 | \examples{ 19 | \donttest{ 20 | cds <- load_a549() 21 | pData(cds) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /man/fData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{fData} 4 | \alias{fData} 5 | \title{Generic to access cds rowData table} 6 | \usage{ 7 | fData(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | rowData table. 14 | } 15 | \description{ 16 | Generic to access cds rowData table 17 | } 18 | \examples{ 19 | \donttest{ 20 | cds <- load_a549() 21 | fData(cds) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /man/clear_cds_slots.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{clear_cds_slots} 4 | \alias{clear_cds_slots} 5 | \title{Clear CDS slots} 6 | \usage{ 7 | clear_cds_slots(cds) 8 | } 9 | \arguments{ 10 | \item{cds}{cell_data_set to be cleared} 11 | } 12 | \value{ 13 | A cell_data_set with only expression, rowData and colData present. 14 | } 15 | \description{ 16 | Function to clear all CDS slots besides colData, rowData and expression data. 17 | } 18 | -------------------------------------------------------------------------------- /man/principal_graph-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{principal_graph,cell_data_set-method} 4 | \alias{principal_graph,cell_data_set-method} 5 | \title{Method to extract principal graph from CDS} 6 | \usage{ 7 | \S4method{principal_graph}{cell_data_set}(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | Principle graph. 14 | } 15 | \description{ 16 | Method to extract principal graph from CDS 17 | } 18 | -------------------------------------------------------------------------------- /man/fData-set-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{fData<-,cell_data_set-method} 4 | \alias{fData<-,cell_data_set-method} 5 | \title{Method to set cds rowData table} 6 | \usage{ 7 | \S4method{fData}{cell_data_set}(x) <- value 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{value}{A data frame to set to colData table.} 13 | } 14 | \value{ 15 | x. 16 | } 17 | \description{ 18 | Method to set cds rowData table 19 | } 20 | -------------------------------------------------------------------------------- /man/size_factors-set.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods-cell_data_set.R 3 | \name{size_factors<-} 4 | \alias{size_factors<-} 5 | \title{Set the size factor values in the cell_data_set} 6 | \usage{ 7 | size_factors(cds) <- value 8 | } 9 | \arguments{ 10 | \item{cds}{A cell_data_set object.} 11 | 12 | \item{value}{the size factor values.} 13 | } 14 | \value{ 15 | An updated cell_data_set object 16 | } 17 | \description{ 18 | Set the size factor values in the cell_data_set 19 | } 20 | -------------------------------------------------------------------------------- /man/counts_row_order-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{counts_row_order,cell_data_set-method} 4 | \alias{counts_row_order,cell_data_set-method} 5 | \title{Method to access cds row order BPCells counts matrix} 6 | \usage{ 7 | \S4method{counts_row_order}{cell_data_set}(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | BPCells row order counts matrix. 14 | } 15 | \description{ 16 | Method to access cds row order BPCells counts matrix 17 | } 18 | -------------------------------------------------------------------------------- /man/fData-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{fData,cell_data_set-method} 4 | \alias{fData,cell_data_set-method} 5 | \title{Method to access cds rowData table} 6 | \usage{ 7 | \S4method{fData}{cell_data_set}(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | rowData table. 14 | } 15 | \description{ 16 | Method to access cds rowData table 17 | } 18 | \examples{ 19 | \donttest{ 20 | cds <- load_a549() 21 | fData(cds) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /man/size_factors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/methods-cell_data_set.R 3 | \name{size_factors} 4 | \alias{size_factors} 5 | \title{Get the size factors from a cds object.} 6 | \usage{ 7 | size_factors(cds) 8 | } 9 | \arguments{ 10 | \item{cds}{A cell_data_set object.} 11 | } 12 | \value{ 13 | An updated cell_data_set object 14 | } 15 | \description{ 16 | A wrapper around \code{colData(cds)$Size_Factor} 17 | } 18 | \examples{ 19 | \donttest{ 20 | cds <- load_a549() 21 | size_factors(cds) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /man/fData-set.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{fData<-} 4 | \alias{fData<-} 5 | \title{Generic to set cds rowData table} 6 | \usage{ 7 | fData(x) <- value 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{value}{A data frame to set to colData table.} 13 | } 14 | \value{ 15 | x. 16 | } 17 | \description{ 18 | Generic to set cds rowData table 19 | } 20 | \examples{ 21 | \donttest{ 22 | cds <- load_a549() 23 | fData(cds)[['row_index']] <- seq(nrow(fData(cds))) 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /man/pData-set.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{pData<-} 4 | \alias{pData<-} 5 | \title{Generic to set cds colData table} 6 | \usage{ 7 | pData(x) <- value 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{value}{A data frame to set to colData table.} 13 | } 14 | \value{ 15 | x. 16 | } 17 | \description{ 18 | Generic to set cds colData table 19 | } 20 | \examples{ 21 | \donttest{ 22 | cds <- load_a549() 23 | pData(cds)[['row_index']] <- seq(nrow(pData(cds))) 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /man/clusters-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{clusters,cell_data_set-method} 4 | \alias{clusters,cell_data_set-method} 5 | \title{Method to extract clusters from CDS object} 6 | \usage{ 7 | \S4method{clusters}{cell_data_set}(x, reduction_method = "UMAP") 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{reduction_method}{Reduced dimension to extract clusters for.} 13 | } 14 | \value{ 15 | Clusters. 16 | } 17 | \description{ 18 | Method to extract clusters from CDS object 19 | } 20 | -------------------------------------------------------------------------------- /man/get_citations.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{get_citations} 4 | \alias{get_citations} 5 | \title{Access citations for methods used during analysis.} 6 | \usage{ 7 | get_citations(cds) 8 | } 9 | \arguments{ 10 | \item{cds}{The cds object to access citations from.} 11 | } 12 | \value{ 13 | A data frame with the methods used and the papers to be cited. 14 | } 15 | \description{ 16 | Access citations for methods used during analysis. 17 | } 18 | \examples{ 19 | { 20 | \dontrun{ 21 | get_citations(cds) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/docker/NOTES: -------------------------------------------------------------------------------- 1 | == Docker image used for Github Actions CI 2 | 3 | The Github Actions CI uses a Docker image that is stored in the github 4 | cole-trapnell-lab docker repository. See github.com/cole-trapnell-lab 5 | 'Packages' tab. 6 | 7 | There are notes for building, uploading, and linking the docker image 8 | to the monocle3 repository in the file 9 | 10 | URL: github.com/cole-trapnell-lab/Docker/monocle3_depend/NOTES 11 | 12 | The Dockerfile and supporting scripts are in 13 | 14 | github.com/cole-trapnell-lab/Docker/monocle3_depend/ 15 | 16 | 17 | -------------------------------------------------------------------------------- /man/principal_graph_aux-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{principal_graph_aux,cell_data_set-method} 4 | \alias{principal_graph_aux,cell_data_set-method} 5 | \title{Method to extract principal graph auxiliary information from CDS} 6 | \usage{ 7 | \S4method{principal_graph_aux}{cell_data_set}(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | Principal graph auxiliary information. 14 | } 15 | \description{ 16 | Method to extract principal graph auxiliary information from CDS 17 | } 18 | -------------------------------------------------------------------------------- /man/partitions-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{partitions,cell_data_set-method} 4 | \alias{partitions,cell_data_set-method} 5 | \title{Method to extract partitions from CDS object} 6 | \usage{ 7 | \S4method{partitions}{cell_data_set}(x, reduction_method = "UMAP") 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{reduction_method}{Reduced dimension to partitions clusters for.} 13 | } 14 | \value{ 15 | Partitions. 16 | } 17 | \description{ 18 | Method to extract partitions from CDS object 19 | } 20 | -------------------------------------------------------------------------------- /man/pseudotime-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{pseudotime,cell_data_set-method} 4 | \alias{pseudotime,cell_data_set-method} 5 | \title{Method to extract pseudotime from CDS object} 6 | \usage{ 7 | \S4method{pseudotime}{cell_data_set}(x, reduction_method = "UMAP") 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{reduction_method}{Reduced dimension to extract clusters for.} 13 | } 14 | \value{ 15 | Pseudotime values. 16 | } 17 | \description{ 18 | Method to extract pseudotime from CDS object 19 | } 20 | -------------------------------------------------------------------------------- /man/soft_assignment.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/learn_graph.R 3 | \name{soft_assignment} 4 | \alias{soft_assignment} 5 | \title{Function to calculate the third term in the objective function} 6 | \usage{ 7 | soft_assignment(X, C, sigma) 8 | } 9 | \arguments{ 10 | \item{X}{input data} 11 | 12 | \item{C}{center of graph (D * K)} 13 | 14 | \item{sigma}{bandwidth parameter} 15 | } 16 | \value{ 17 | a matrix with diagonal element as 1 while other elements as zero 18 | (eye matrix) 19 | } 20 | \description{ 21 | Function to calculate the third term in the objective function 22 | } 23 | -------------------------------------------------------------------------------- /man/repmat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/learn_graph.R 3 | \name{repmat} 4 | \alias{repmat} 5 | \title{function to reproduce the behavior of repmat function in matlab to replicate 6 | and tile an matrix} 7 | \usage{ 8 | repmat(X, m, n) 9 | } 10 | \arguments{ 11 | \item{X}{matrix for tiling and replicate the data} 12 | 13 | \item{m}{a numeric value for tiling a matrix} 14 | 15 | \item{n}{a numeric value for tiling a matrix} 16 | } 17 | \value{ 18 | a matrix 19 | } 20 | \description{ 21 | function to reproduce the behavior of repmat function in matlab to replicate 22 | and tile an matrix 23 | } 24 | -------------------------------------------------------------------------------- /man/counts_row_order.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{counts_row_order} 4 | \alias{counts_row_order} 5 | \title{Generic to access cds row order BPCells counts matrix.} 6 | \usage{ 7 | counts_row_order(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | BPCells row order counts matrix. 14 | } 15 | \description{ 16 | Generic to access cds row order BPCells counts matrix. 17 | } 18 | \examples{ 19 | \donttest{ 20 | cds <- load_a549(matrix_control=list(matrix_class='BPCells')) 21 | mat_row_order <- counts_row_order(cds) 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /man/pData-set-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{pData<-,cell_data_set-method} 4 | \alias{pData<-,cell_data_set-method} 5 | \title{Method to set cds colData table} 6 | \usage{ 7 | \S4method{pData}{cell_data_set}(x) <- value 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{value}{A data frame to set to colData table.} 13 | } 14 | \value{ 15 | x. 16 | } 17 | \description{ 18 | Method to set cds colData table 19 | } 20 | \examples{ 21 | \donttest{ 22 | cds <- load_a549() 23 | pData(cds)[['row_index']] <- seq(nrow(pData(cds))) 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /man/load_worm_l2.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/io.R 3 | \name{load_worm_l2} 4 | \alias{load_worm_l2} 5 | \title{Build a cell_data_set from C. elegans L2 data.} 6 | \usage{ 7 | load_worm_l2(matrix_control = list()) 8 | } 9 | \arguments{ 10 | \item{matrix_control}{A list used to control how the counts matrix is stored 11 | in the CDS. By default, Monocle3 stores the counts matrix in-memory as a 12 | sparse matrix. Setting 'matrix_control=list(matrix_class="BPCells")', 13 | stores the matrix on-disk as a sparse matrix.} 14 | } 15 | \value{ 16 | cds object 17 | } 18 | \description{ 19 | Build a cell_data_set from C. elegans L2 data. 20 | } 21 | -------------------------------------------------------------------------------- /man/get_genome_in_matrix_path.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/load_cellranger_data.R 3 | \name{get_genome_in_matrix_path} 4 | \alias{get_genome_in_matrix_path} 5 | \title{Get a genome from Cell Ranger output} 6 | \usage{ 7 | get_genome_in_matrix_path(matrix_path, genome = NULL) 8 | } 9 | \arguments{ 10 | \item{matrix_path}{Path to a matrices directory produced by the Cell Ranger 11 | pipeline} 12 | 13 | \item{genome}{Genome to specifically check for, otherwise will check for 14 | whatever genome(s) exist there} 15 | } 16 | \value{ 17 | A string representing the genome found 18 | } 19 | \description{ 20 | Get a genome from Cell Ranger output 21 | } 22 | -------------------------------------------------------------------------------- /man/load_worm_embryo.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/io.R 3 | \name{load_worm_embryo} 4 | \alias{load_worm_embryo} 5 | \title{Build a cell_data_set from C. elegans embryo data.} 6 | \usage{ 7 | load_worm_embryo(matrix_control = list()) 8 | } 9 | \arguments{ 10 | \item{matrix_control}{A list used to control how the counts matrix is stored 11 | in the CDS. By default, Monocle3 stores the counts matrix in-memory as a 12 | sparse matrix. Setting 'matrix_control=list(matrix_class="BPCells")', 13 | stores the matrix on-disk as a sparse matrix.} 14 | } 15 | \value{ 16 | cds object 17 | } 18 | \description{ 19 | Build a cell_data_set from C. elegans embryo data. 20 | } 21 | -------------------------------------------------------------------------------- /man/load_a549.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/io.R 3 | \name{load_a549} 4 | \alias{load_a549} 5 | \title{Build a small cell_data_set.} 6 | \usage{ 7 | load_a549(matrix_control = list()) 8 | } 9 | \arguments{ 10 | \item{matrix_control}{A list used to control how the counts matrix is stored 11 | in the CDS. By default, Monocle3 stores the counts matrix in-memory as a 12 | sparse matrix. Setting 'matrix_control=list(matrix_class="BPCells")', 13 | stores the matrix on-disk as a sparse matrix.} 14 | } 15 | \value{ 16 | cds object 17 | } 18 | \description{ 19 | Build a small cell_data_set. 20 | } 21 | \examples{ 22 | \donttest{ 23 | cds <- load_a549() 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /man/model_predictions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/expr_models.R 3 | \name{model_predictions} 4 | \alias{model_predictions} 5 | \title{Predict values of new data using fit_models model.} 6 | \usage{ 7 | model_predictions(model_tbl, new_data, type = "response") 8 | } 9 | \arguments{ 10 | \item{model_tbl}{A tibble of model objects, generally output of 11 | \code{\link{fit_models}}.} 12 | 13 | \item{new_data}{A data frame of new data to be passed to predict for 14 | prediction.} 15 | 16 | \item{type}{String of type to pass to predict. Default is "response".} 17 | } 18 | \value{ 19 | Prediction matrix. 20 | } 21 | \description{ 22 | Predict new data values and return as a matrix 23 | } 24 | -------------------------------------------------------------------------------- /man/generate_centers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/learn_graph.R 3 | \name{generate_centers} 4 | \alias{generate_centers} 5 | \title{Function to reproduce the behavior of eye function in matlab} 6 | \usage{ 7 | generate_centers(X, W, P, param.gamma) 8 | } 9 | \arguments{ 10 | \item{X}{input data} 11 | 12 | \item{W}{the principal graph matrix} 13 | 14 | \item{P}{the cluster assignment matrix} 15 | 16 | \item{param.gamma}{regularization parameter for k-means (the prefix of 17 | 'param' is used to avoid name collision with gamma)} 18 | } 19 | \value{ 20 | A matrix C for the centers for principal graph 21 | } 22 | \description{ 23 | Function to reproduce the behavior of eye function in matlab 24 | } 25 | -------------------------------------------------------------------------------- /man/align_transform.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/projection.R 3 | \name{align_transform} 4 | \alias{align_transform} 5 | \title{Apply an alignment transform model to a cell_data_set.} 6 | \usage{ 7 | align_transform(cds, reduction_method = c("Aligned")) 8 | } 9 | \arguments{ 10 | \item{cds}{a cell_data_set to be transformed.} 11 | 12 | \item{reduction_method}{a previously loaded transform 13 | model that is used to reduce the dimensions of the 14 | count matrix in the cell_data_set. The "Aligned" 15 | transform is not supported.} 16 | } 17 | \value{ 18 | The cds is returned without processing. 19 | } 20 | \description{ 21 | align_transform is not supported. Co-embed your 22 | data sets if you need batch correction. 23 | } 24 | -------------------------------------------------------------------------------- /man/plot_mito_umi_per_cell.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_mito_umi_per_cell} 4 | \alias{plot_mito_umi_per_cell} 5 | \title{Plot a histogram of the percentage of UMIs mapping to mitochondria for each cell.} 6 | \usage{ 7 | plot_mito_umi_per_cell(cds, max_mito_pct = .max_mito_pct, pseudocount = 0.001) 8 | } 9 | \arguments{ 10 | \item{cds}{A cell_data_set for plotting.} 11 | 12 | \item{max_mito_pct}{Cutoff for the maximum percentage of UMIs mapping to mitochondria.} 13 | 14 | \item{pseudocount}{Value to add to the percentages before taking the log. Note that this is in terms of percent, not fractional.} 15 | } 16 | \value{ 17 | A ggplot2 object. 18 | } 19 | \description{ 20 | Plot a histogram of the percentage of UMIs mapping to mitochondria for each cell. 21 | } 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | ** If this is a question and not a bug report or enhancement request, please post to our google group at https://groups.google.com/forum/#!forum/monocle-3-users** 10 | 11 | **Describe the bug** 12 | A clear and concise description of what the bug is. 13 | 14 | **To Reproduce** 15 | The code that produced the bug: 16 | 17 | **traceback()** 18 | After the error, run traceback() in R and post the output: 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **sessionInfo():** 27 | Run sessionInfo() in R and post the output 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /man/detect_genes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{detect_genes} 4 | \alias{detect_genes} 5 | \title{Detects genes above minimum threshold.} 6 | \usage{ 7 | detect_genes(cds, min_expr = 0) 8 | } 9 | \arguments{ 10 | \item{cds}{Input cell_data_set object.} 11 | 12 | \item{min_expr}{Numeric indicating expression threshold} 13 | } 14 | \value{ 15 | Updated cell_data_set object 16 | } 17 | \description{ 18 | For each gene in a cell_data_set object, detect_genes counts 19 | how many cells are expressed above a minimum threshold. In addition, for 20 | each cell, detect_genes counts the number of genes above this threshold that 21 | are detectable. Results are added as columns num_cells_expressed and 22 | num_genes_expressed in the rowData and colData tables respectively. 23 | } 24 | \examples{ 25 | \dontrun{ 26 | cds <- detect_genes(cds, min_expr=0.1) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testing/notes.todo.20230425.txt: -------------------------------------------------------------------------------- 1 | Cole's notes 2 | o look at aggregate matrix functino 3 | o top_markers uses aggregate_matrix 4 | o top_markers uses a generalized linear regression to (fit something) by each gene. This is slow. Consider alternatives. 5 | o something about pulling out genes and may be related to aggregate matrix 6 | o plotting of expression of genes (pull out one gene?) 7 | 8 | My notes 9 | o binarize BPCells matrix in utils.R:normalized_counts() 10 | o as.numeric on BPCells matrix in find_markers.R:test_marker_for_cell_group 11 | o convert matrix to type double in utils.R:normalized_counts() 12 | o md5 checksum of BPCells matrix? This is a tough one because of queued operations, I think. Can I read out the matrix column-by-column without collapsing the operations internally? 13 | o review and tabulate changes done, required, and unknown based on the searches for counts(cds), exprs(cds), and assay(s)(cds) 14 | -------------------------------------------------------------------------------- /man/choose_cells.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/select_cells.R 3 | \name{choose_cells} 4 | \alias{choose_cells} 5 | \title{Choose cells interactively to subset a cds} 6 | \usage{ 7 | choose_cells( 8 | cds, 9 | reduction_method = c("UMAP", "tSNE", "PCA", "Aligned"), 10 | clear_cds = FALSE, 11 | return_list = FALSE 12 | ) 13 | } 14 | \arguments{ 15 | \item{cds}{CDS object to subset} 16 | 17 | \item{reduction_method}{The reduction method to plot while choosing cells.} 18 | 19 | \item{clear_cds}{Logical, clear CDS slots before returning. 20 | After clearing the cds, re-run processing from preprocess_cds(), ... 21 | Default is FALSE.} 22 | 23 | \item{return_list}{Logical, return a list of cells instead of a subsetted 24 | CDS object.} 25 | } 26 | \value{ 27 | A subset CDS object. If return_list = FALSE, a list of cell names. 28 | } 29 | \description{ 30 | Choose cells interactively to subset a cds 31 | } 32 | -------------------------------------------------------------------------------- /man/compare_models.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/expr_models.R 3 | \name{compare_models} 4 | \alias{compare_models} 5 | \title{Compare goodness of fit of two models.} 6 | \usage{ 7 | compare_models(model_tbl_full, model_tbl_reduced) 8 | } 9 | \arguments{ 10 | \item{model_tbl_full}{A tibble of model objects, generally output of 11 | \code{\link{fit_models}}, to be compared with \code{model_tbl_reduced}} 12 | 13 | \item{model_tbl_reduced}{A tibble of model objects, generally output of 14 | \code{\link{fit_models}}, to be compared with \code{model_tbl_full}.} 15 | } 16 | \value{ 17 | The result of a likelihood test by gene. 18 | } 19 | \description{ 20 | Compares goodness of fit for two ways of fitting a set of genes' 21 | expression using a likelihood ratio test. The likelihood ratio 22 | test helps one decide whether the improvement in fit is large enough 23 | to justify the additional complexity of extra terms in the full 24 | model in comparison to the reduced model. 25 | } 26 | -------------------------------------------------------------------------------- /man/plot_umi_per_cell.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_umi_per_cell} 4 | \alias{plot_umi_per_cell} 5 | \title{Plot a histogram of the number of UMIs per cell with an optional vertical line showing the cutoff for outliers.} 6 | \usage{ 7 | plot_umi_per_cell(cds, max_zscore = NULL, min_rna_umi = NULL) 8 | } 9 | \arguments{ 10 | \item{cds}{A cell_data_set for plotting.} 11 | 12 | \item{max_zscore}{Cutoff for the maximum Z-score of the log-transformed UMIs per cell. If NULL, then \code{min_rna_umi} must be specified.} 13 | 14 | \item{min_rna_umi}{Cutoff for the minimum number of UMIs per cell. Ignored if \code{max_zscore} is specified.} 15 | } 16 | \value{ 17 | A ggplot2 object. 18 | } 19 | \description{ 20 | If \code{max_zscore} is specified, then there is both a high and a low cutoff, both of which are determined by Z-scoring the log-transformed UMI counts. Otherwise if \code{min_rna_umi} is specified, then there is only a low cutoff. If neither is specified, then no cutoff is shown. 21 | } 22 | -------------------------------------------------------------------------------- /man/cell_data_set.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cell_data_set.R 3 | \docType{class} 4 | \name{cell_data_set} 5 | \alias{cell_data_set} 6 | \alias{cell_data_set-class} 7 | \title{The cell_data_set class} 8 | \description{ 9 | The main class used by Monocle3 to hold single-cell expression data. 10 | cell_data_set extends the Bioconductor SingleCellExperiment class. 11 | } 12 | \details{ 13 | This class is initialized from a matrix of expression values along with cell 14 | and feature metadata. 15 | } 16 | \section{Fields}{ 17 | 18 | \describe{ 19 | \item{\code{reduce_dim_aux}}{SimpleList, auxiliary information from reduced 20 | dimension.} 21 | 22 | \item{\code{principal_graph_aux}}{SimpleList, auxiliary information from principal 23 | graph construction} 24 | 25 | \item{\code{principal_graph}}{SimpleList of igraph objects containing principal 26 | graphs for different dimensionality reduction.} 27 | 28 | \item{\code{clusters}}{SimpleList of cluster information for different 29 | dimensionality reduction.} 30 | }} 31 | 32 | -------------------------------------------------------------------------------- /man/make_nn_index.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nearest_neighbors.R 3 | \name{make_nn_index} 4 | \alias{make_nn_index} 5 | \title{Make a nearest neighbor index.} 6 | \usage{ 7 | make_nn_index(subject_matrix, nn_control = list(), verbose = FALSE) 8 | } 9 | \arguments{ 10 | \item{subject_matrix}{the matrix used to build the 11 | index.} 12 | 13 | \item{nn_control}{a list of parameters used to make the 14 | nearest neighbor index. See the set_nn_control help 15 | for details.} 16 | 17 | \item{verbose}{a boolean indicating whether to emit verbose output.} 18 | } 19 | \value{ 20 | a nearest neighbor index. 21 | } 22 | \description{ 23 | Make a nearest neighbor index from the 24 | subject_matrix using either the default nearest 25 | neighbor method or the method specified in the 26 | nn_control list parameter. The function returns 27 | the index. 28 | } 29 | \examples{ 30 | \donttest{ 31 | cds <- load_a549() 32 | cds <- preprocess_cds(cds) 33 | nn_index <- make_nn_index(SingleCellExperiment::reducedDims(cds)[['PCA']]) 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /man/convert_counts_matrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/matrix.R 3 | \name{convert_counts_matrix} 4 | \alias{convert_counts_matrix} 5 | \title{Convert the counts matrix class in the given CDS.} 6 | \usage{ 7 | convert_counts_matrix(cds, matrix_control = list()) 8 | } 9 | \arguments{ 10 | \item{cds}{cell_data_set The cell_data_set that has the 11 | counts matrix to be converted.} 12 | 13 | \item{matrix_control}{list A list of matrix control 14 | values used to convert the counts matrix. If the 15 | counts matrix in the cds is the same as the desired 16 | counts matrix, it is not altered. matrix_control is 17 | required.} 18 | } 19 | \value{ 20 | cell_data_set The cell_data_set with the converted 21 | counts matrix. 22 | } 23 | \description{ 24 | Converts the counts matrix that is in the 25 | given CDS to the matrix_class specified in the 26 | matrix_control list. 27 | } 28 | \examples{ 29 | cds <- load_a549() 30 | str(counts(cds)) 31 | cds <- convert_counts_matrix(cds, matrix_control=list(matrix_class='BPCells')) 32 | str(counts(cds)) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /man/normalized_counts.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{normalized_counts} 4 | \alias{normalized_counts} 5 | \title{Return a size-factor normalized and (optionally) log-transformed expression 6 | matrix} 7 | \usage{ 8 | normalized_counts( 9 | cds, 10 | norm_method = c("log", "binary", "size_only"), 11 | pseudocount = 1 12 | ) 13 | } 14 | \arguments{ 15 | \item{cds}{A CDS object to calculate normalized expression matrix from.} 16 | 17 | \item{norm_method}{String indicating the normalization method. Options are 18 | "log" (Default), "binary" and "size_only".} 19 | 20 | \item{pseudocount}{A pseudocount to add before log transformation. Ignored 21 | if norm_method is not "log". Default is 1.} 22 | } 23 | \value{ 24 | Size-factor normalized, and optionally log-transformed, expression 25 | matrix. 26 | } 27 | \description{ 28 | Return a size-factor normalized and (optionally) log-transformed expression 29 | matrix 30 | } 31 | \examples{ 32 | \donttest{ 33 | cds <- load_a549() 34 | normalized_matrix <- normalized_counts(cds) 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /man/load_monocle_objects.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/io.R 3 | \name{load_monocle_objects} 4 | \alias{load_monocle_objects} 5 | \title{Load a full Monocle3 cell_data_set.} 6 | \usage{ 7 | load_monocle_objects(directory_path, matrix_control = list()) 8 | } 9 | \arguments{ 10 | \item{directory_path}{a string giving the name of the directory 11 | from which to read the saved cell_data_set files.} 12 | 13 | \item{matrix_control}{a list that is used only to set the 14 | BPCells matrix path when the saved cell_data_set has the 15 | counts matrix stored as a BPCells on-disk matrix. By default, 16 | the BPCells matrix directory path is set to the current 17 | working directory.} 18 | } 19 | \value{ 20 | a cell_data_set. 21 | } 22 | \description{ 23 | Load a full Monocle3 cell_data_set, which was saved using 24 | save_monocle_objects(). For more information read the help 25 | information for save_monocle_objects(). 26 | } 27 | \examples{ 28 | \dontrun{ 29 | cds <- load_a549() 30 | save_monocle_objects(cds, 'mo') 31 | cds1 <- load_monocle_objects('mo') 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /man/set_cds_nn_index.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nearest_neighbors.R 3 | \name{set_cds_nn_index} 4 | \alias{set_cds_nn_index} 5 | \title{Set a nearest neighor index in the cell_data_set.} 6 | \usage{ 7 | set_cds_nn_index( 8 | cds, 9 | reduction_method = c("UMAP", "PCA", "LSI", "Aligned", "tSNE"), 10 | nn_index, 11 | verbose = FALSE 12 | ) 13 | } 14 | \arguments{ 15 | \item{cds}{a cell_data_set in which to store the nearest 16 | neighbor index.} 17 | 18 | \item{reduction_method}{a string giving the reduced 19 | dimension matrix used to make the nn_index nearest 20 | neighbor index, and determines where the index is 21 | stored in the cell_data_set.} 22 | 23 | \item{nn_index}{a nearest neighbor index to store in cds.} 24 | 25 | \item{verbose}{a boolean indicating whether to emit verbose output.} 26 | } 27 | \value{ 28 | a cell_data_set with the stored index. 29 | } 30 | \description{ 31 | Store the given nearest neighbor index 32 | in the cell_data_set. The reduction_method parameter 33 | tells set_cds_nn_index where in the cell_data_set to 34 | store the index. 35 | } 36 | -------------------------------------------------------------------------------- /man/estimate_size_factors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{estimate_size_factors} 4 | \alias{estimate_size_factors} 5 | \title{Function to calculate size factors for single-cell RNA-seq data} 6 | \usage{ 7 | estimate_size_factors( 8 | cds, 9 | round_exprs = TRUE, 10 | method = c("mean-geometric-mean-total", "mean-geometric-mean-log-total") 11 | ) 12 | } 13 | \arguments{ 14 | \item{cds}{The cell_data_set} 15 | 16 | \item{round_exprs}{A logic flag to determine whether or not the expression 17 | value should be rounded} 18 | 19 | \item{method}{A string to specify the size factor calculation approach. 20 | Options are "mean-geometric-mean-total" (default), 21 | "mean-geometric-mean-log-total".} 22 | } 23 | \value{ 24 | Updated cell_data_set object with a new colData column called 25 | 'Size_Factor'. 26 | } 27 | \description{ 28 | Function to calculate size factors for single-cell RNA-seq data 29 | } 30 | \examples{ 31 | \donttest{ 32 | cds <- load_a549() 33 | colData(cds)[['Size_Factor']] <- NULL 34 | cds <- estimate_size_factors(cds) 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /man/plot_pc_variance_explained.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_pc_variance_explained} 4 | \alias{plot_pc_variance_explained} 5 | \title{Plots the fraction of variance explained by the each component based on 6 | PCA from the normalized expression data determined using preprocess_cds. 7 | This is the fraction of the component variance relative to the variance 8 | of the components retained in the PCA; not the total variance.} 9 | \usage{ 10 | plot_pc_variance_explained(cds) 11 | } 12 | \arguments{ 13 | \item{cds}{cell_data_set of the experiment.} 14 | } 15 | \value{ 16 | ggplot object. 17 | } 18 | \description{ 19 | Plots the fraction of variance explained by the each component based on 20 | PCA from the normalized expression data determined using preprocess_cds. 21 | This is the fraction of the component variance relative to the variance 22 | of the components retained in the PCA; not the total variance. 23 | } 24 | \examples{ 25 | \donttest{ 26 | cds <- load_a549() 27 | cds <- preprocess_cds(cds) 28 | plot_pc_variance_explained(cds) 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2019 Cole Trapnell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /man/generate_garnett_marker_file.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/find_markers.R 3 | \name{generate_garnett_marker_file} 4 | \alias{generate_garnett_marker_file} 5 | \title{Generate a Garnett marker file from top_markers output.} 6 | \usage{ 7 | generate_garnett_marker_file( 8 | marker_test_res, 9 | file = "./marker_file.txt", 10 | max_genes_per_group = 10, 11 | remove_duplicate_genes = FALSE 12 | ) 13 | } 14 | \arguments{ 15 | \item{marker_test_res}{Tibble of top markers, output of 16 | \code{\link{top_markers}}.} 17 | 18 | \item{file}{Path to the marker file to be generated. Default is 19 | "./marker_file.txt".} 20 | 21 | \item{max_genes_per_group}{Numeric, the maximum number of genes to output 22 | per cell type entry. Default is 10.} 23 | 24 | \item{remove_duplicate_genes}{Logical indicating whether marker genes that 25 | mark multiple cell groups should be excluded. Default is FALSE. When 26 | FALSE, a message will be emitted when duplicates are present.} 27 | } 28 | \value{ 29 | None, marker file is written to \code{file} parameter location. 30 | } 31 | \description{ 32 | Generate a Garnett marker file from top_markers output. 33 | } 34 | -------------------------------------------------------------------------------- /man/plot_umi_per_cell_and_perturbation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_umi_per_cell_and_perturbation} 4 | \alias{plot_umi_per_cell_and_perturbation} 5 | \title{Make a boxplot of the number of UMIs per cell, with each perturbation as a separate box. Optionally facet by a second value.} 6 | \usage{ 7 | plot_umi_per_cell_and_perturbation( 8 | cds, 9 | perturbation_col = "perturbation", 10 | facet_by = NULL, 11 | color_palette = NULL, 12 | yticks = NULL 13 | ) 14 | } 15 | \arguments{ 16 | \item{cds}{A cell_data_set for plotting.} 17 | 18 | \item{perturbation_col}{How to group the cells for the plot. Must be a column of the colData.} 19 | 20 | \item{facet_by}{Facet the plot by this column of the colData. Each unique value is its own facet.} 21 | 22 | \item{color_palette}{List of colors to color perturbation groups. Default is NULL. When NULL, use a default set.} 23 | 24 | \item{yticks}{List of numeric values to put on the y-axis ticks.} 25 | } 26 | \value{ 27 | A ggplot2 object. 28 | } 29 | \description{ 30 | Make a boxplot of the number of UMIs per cell, with each perturbation as a separate box. Optionally facet by a second value. 31 | } 32 | -------------------------------------------------------------------------------- /R/methods-cell_data_set.R: -------------------------------------------------------------------------------- 1 | #' Methods for the cell_data_set class 2 | #' @name cell_data_set-methods 3 | #' @docType methods 4 | #' @rdname cell_data_set-methods 5 | #' @param object The cell_data_set object 6 | setValidity( "cell_data_set", function( object ) { 7 | TRUE 8 | } ) 9 | 10 | #' Set the size factor values in the cell_data_set 11 | #' 12 | #' @param cds A cell_data_set object. 13 | #' @param value the size factor values. 14 | #' @return An updated cell_data_set object 15 | `size_factors<-` <- function( cds, value ) { 16 | stopifnot( methods::is( cds, "cell_data_set" ) ) 17 | colData(cds)$Size_Factor <- value 18 | methods::validObject( cds ) 19 | cds 20 | } 21 | 22 | #' Get the size factors from a cds object. 23 | #' 24 | #' A wrapper around \code{colData(cds)$Size_Factor} 25 | #' 26 | #' @param cds A cell_data_set object. 27 | #' @return An updated cell_data_set object 28 | #' 29 | #' @examples 30 | #' \donttest{ 31 | #' cds <- load_a549() 32 | #' size_factors(cds) 33 | #' } 34 | #' 35 | #' @export 36 | size_factors <- function( cds ) { 37 | stopifnot( methods::is( cds, "cell_data_set" ) ) 38 | sf <- colData(cds)$Size_Factor 39 | names( sf ) <- colnames( SingleCellExperiment::counts(cds) ) 40 | sf 41 | } 42 | 43 | -------------------------------------------------------------------------------- /man/calc_principal_graph.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/learn_graph.R 3 | \name{calc_principal_graph} 4 | \alias{calc_principal_graph} 5 | \title{Function to automatically learn the structure of data by either using 6 | L1-graph or the spanning-tree formulization} 7 | \usage{ 8 | calc_principal_graph( 9 | X, 10 | C0, 11 | maxiter = 10, 12 | eps = 1e-05, 13 | L1.gamma = 0.5, 14 | L1.sigma = 0.01, 15 | verbose = TRUE 16 | ) 17 | } 18 | \arguments{ 19 | \item{X}{the input data DxN} 20 | 21 | \item{C0}{the initialization of centroids} 22 | 23 | \item{maxiter}{maximum number of iteration} 24 | 25 | \item{eps}{relative objective difference} 26 | 27 | \item{L1.gamma}{regularization parameter for k-means (the prefix of 'param' 28 | is used to avoid name collision with gamma)} 29 | 30 | \item{L1.sigma}{bandwidth parameter} 31 | 32 | \item{verbose}{emit results from iteration} 33 | } 34 | \value{ 35 | a list of X, C, W, P, objs 36 | X is the input data 37 | C is the centers for principal graph 38 | W is the principal graph matrix 39 | P is the cluster assignment matrix 40 | objs is the objective value for the function 41 | } 42 | \description{ 43 | Function to automatically learn the structure of data by either using 44 | L1-graph or the spanning-tree formulization 45 | } 46 | -------------------------------------------------------------------------------- /man/load_transform_models.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/io.R 3 | \name{load_transform_models} 4 | \alias{load_transform_models} 5 | \title{Load transform models into a cell_data_set.} 6 | \usage{ 7 | load_transform_models(cds, directory_path) 8 | } 9 | \arguments{ 10 | \item{cds}{a cell_data_set to be transformed using the models.} 11 | 12 | \item{directory_path}{a string giving the name of the directory 13 | from which to read the model files. The model file directory 14 | is made by either save_transform_models() or 15 | save_monocle_objects().} 16 | } 17 | \value{ 18 | a cell_data_set with the transform models loaded by 19 | load_transform_models(). 20 | } 21 | \description{ 22 | Load transform models into a cell_data_set where the transform 23 | models directory was made using either save_transform_models() 24 | or save_monocle_objects(). This function over-writes existing 25 | models in the cell_data_set. For more information see the 26 | help information for save_transform_models() and 27 | save_monocle_objects(). 28 | } 29 | \examples{ 30 | \dontrun{ 31 | cds <- load_a549() 32 | cds <- preprocess_cds(cds) 33 | cds <- reduce_dimension(cds) 34 | save_transform_models(cds, 'tm') 35 | cds1 <- load_a549() 36 | cds1 <- load_transform_models(cds1, 'tm') 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /man/load_mtx_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/io.R 3 | \name{load_mtx_data} 4 | \alias{load_mtx_data} 5 | \title{Load data from matrix market format} 6 | \usage{ 7 | load_mtx_data( 8 | mat_path, 9 | gene_anno_path, 10 | cell_anno_path, 11 | umi_cutoff = 100, 12 | matrix_control = list() 13 | ) 14 | } 15 | \arguments{ 16 | \item{mat_path}{Path to the .mtx matrix market file.} 17 | 18 | \item{gene_anno_path}{Path to gene annotation file.} 19 | 20 | \item{cell_anno_path}{Path to cell annotation file.} 21 | 22 | \item{umi_cutoff}{UMI per cell cutoff, default is 100.} 23 | 24 | \item{matrix_control}{A list used to control how the counts matrix is stored 25 | in the CDS. By default, Monocle3 stores the counts matrix in-memory as a 26 | sparse matrix. Setting 'matrix_control=list(matrix_class="BPCells")', 27 | stores the matrix BPCells on-disk as a sparse matrix.} 28 | } 29 | \value{ 30 | cds object 31 | } 32 | \description{ 33 | Load data from matrix market format 34 | } 35 | \examples{ 36 | \donttest{ 37 | pmat<-system.file("extdata", "matrix.mtx.gz", package = "monocle3") 38 | prow<-system.file("extdata", "features_c3h0.txt", package = "monocle3") 39 | pcol<-system.file("extdata", "barcodes_c2h0.txt", package = "monocle3") 40 | cds <- load_mtx_data( pmat, prow, pcol) 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /man/mc_es_apply.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{mc_es_apply} 4 | \alias{mc_es_apply} 5 | \title{Multicore apply-like function for cell_data_set} 6 | \usage{ 7 | mc_es_apply( 8 | cds, 9 | MARGIN, 10 | FUN, 11 | required_packages, 12 | cores = 1, 13 | convert_to_dense = TRUE, 14 | reduction_method = "UMAP", 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{cds}{A cell_data_set object.} 20 | 21 | \item{MARGIN}{The margin to apply to, either 1 for rows (samples) or 2 for 22 | columns (features).} 23 | 24 | \item{FUN}{Any function.} 25 | 26 | \item{required_packages}{A list of packages FUN will need. Failing to 27 | provide packages needed by FUN will generate errors in worker threads.} 28 | 29 | \item{cores}{The number of cores to use for evaluation.} 30 | 31 | \item{convert_to_dense}{Whether to force conversion of a sparse matrix to a 32 | dense one before calling FUN.} 33 | 34 | \item{reduction_method}{character, the method used to reduce dimension. 35 | Default "UMAP".} 36 | 37 | \item{...}{Additional parameters for FUN.} 38 | } 39 | \value{ 40 | The result of with(colData(cds) apply(counts(cds)), MARGIN, FUN, ...)) 41 | } 42 | \description{ 43 | mc_es_apply computes the row-wise or column-wise results of FUN, just like 44 | esApply. Variables in colData from cds are available in FUN. 45 | } 46 | -------------------------------------------------------------------------------- /man/set_cds_row_order_matrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/matrix.R 3 | \name{set_cds_row_order_matrix} 4 | \alias{set_cds_row_order_matrix} 5 | \title{Set the row-major order counts matrix in the assays slot of the CDS when the 6 | CDS has a BPCells counts matrix.} 7 | \usage{ 8 | set_cds_row_order_matrix(cds) 9 | } 10 | \arguments{ 11 | \item{cds}{cell_data_set A cell_data_set.} 12 | } 13 | \value{ 14 | cell_data_set The cell_data_set with the additional row-major order 15 | counts matrix. 16 | } 17 | \description{ 18 | By default, BPCells stores matrices as one-dimensional vectors in column-major order, as does R. 19 | As a result, column access is fast and row access is slow. We use BPCell's ability to also store and 20 | access matrices in row-major order, which gives fast row access. The function set_cds_row_order_matrix 21 | creates the row-major order matrix and stores it in the assays slot of the CDS with the name 22 | "counts_row_order". The two copies of the counts matrix must have the same count values so if you 23 | replace or change the CDS's counts matrix, you must also update the \code{counts_row_order} matrix, which 24 | you can do using this function set_cds_row_order_matrix. 25 | } 26 | \examples{ 27 | cds <- load_a549(matrix_control=list(matrix_class='BPCells')) 28 | cds <- set_cds_row_order_matrix(cds) 29 | str(cds) 30 | 31 | } 32 | -------------------------------------------------------------------------------- /man/search_nn_matrix.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nearest_neighbors.R 3 | \name{search_nn_matrix} 4 | \alias{search_nn_matrix} 5 | \title{Search a subject matrix for nearest neighbors to a query_matrix.} 6 | \usage{ 7 | search_nn_matrix( 8 | subject_matrix, 9 | query_matrix, 10 | k = 25, 11 | nn_control = list(), 12 | verbose = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{subject_matrix}{a matrix used to build a nearest neighbor index.} 17 | 18 | \item{query_matrix}{a matrix used to search the subject_matrix 19 | nearest neighbor index.} 20 | 21 | \item{k}{an integer for the number of nearest neighbors to return for 22 | each cell. Default is 25.} 23 | 24 | \item{nn_control}{a list of parameters used to make and search the nearest 25 | neighbor index. See the set_nn_control help for details.} 26 | 27 | \item{verbose}{a boolean indicating whether to emit verbose output.} 28 | } 29 | \value{ 30 | a list list(nn.idx, nn.dists) where nn.idx is 31 | a matrix of nearest neighbor indices and nn.dists is a matrix of 32 | the distance between the index given by the row number and the index 33 | given in nn.idx. If the query_matrix is the same as the subject 34 | matrix, the index given by the row number should be in the row, usually 35 | in the first column. 36 | } 37 | \description{ 38 | Make a nearest neighbors index using the subject matrix and 39 | search it for nearest neighbors to the query_matrix. 40 | } 41 | -------------------------------------------------------------------------------- /man/clusters.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{clusters} 4 | \alias{clusters} 5 | \title{Generic to extract clusters from CDS object} 6 | \usage{ 7 | clusters(x, reduction_method = "UMAP") 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{reduction_method}{Reduced dimension to extract clusters for.} 13 | } 14 | \value{ 15 | Clusters. 16 | } 17 | \description{ 18 | Generic to extract clusters from CDS object 19 | } 20 | \examples{ 21 | \donttest{ 22 | cell_metadata <- readRDS(system.file('extdata', 23 | 'worm_embryo/worm_embryo_coldata.rds', 24 | package='monocle3')) 25 | gene_metadata <- readRDS(system.file('extdata', 26 | 'worm_embryo/worm_embryo_rowdata.rds', 27 | package='monocle3')) 28 | expression_matrix <- readRDS(system.file('extdata', 29 | 'worm_embryo/worm_embryo_expression_matrix.rds', 30 | package='monocle3')) 31 | cds <- new_cell_data_set(expression_data=expression_matrix, 32 | cell_metadata=cell_metadata, 33 | gene_metadata=gene_metadata) 34 | 35 | cds <- preprocess_cds(cds) 36 | cds <- reduce_dimension(cds) 37 | cds <- cluster_cells(cds) 38 | clusters_factors <- clusters(cds, "UMAP") 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /man/choose_graph_segments.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/select_cells.R 3 | \name{choose_graph_segments} 4 | \alias{choose_graph_segments} 5 | \title{Choose cells along the path of a principal graph} 6 | \usage{ 7 | choose_graph_segments( 8 | cds, 9 | reduction_method = "UMAP", 10 | starting_pr_node = NULL, 11 | ending_pr_nodes = NULL, 12 | return_list = FALSE, 13 | clear_cds = TRUE 14 | ) 15 | } 16 | \arguments{ 17 | \item{cds}{CDS object to be subsetted.} 18 | 19 | \item{reduction_method}{The reduction method to plot while choosing cells. 20 | Currently only "UMAP" is supported.} 21 | 22 | \item{starting_pr_node}{NULL, or a string with the name of the starting 23 | principal node to be used. You can see the principal nodes in your dataset 24 | by using plot_cells with label_principal_points = TRUE.} 25 | 26 | \item{ending_pr_nodes}{NULL, or one or more strings with the name(s) of the 27 | ending principal node(s) to be used. You can see the principal nodes in 28 | your dataset by using plot_cells with label_principal_points = TRUE.} 29 | 30 | \item{return_list}{Logical, return a list of cells instead of a subsetted 31 | CDS object.} 32 | 33 | \item{clear_cds}{Logical, clear CDS slots before returning. 34 | After clearing the cds, re-run processing from preprocess_cds(), ... 35 | Default is TRUE.} 36 | } 37 | \value{ 38 | A subset CDS object. If return_list = FALSE, a list of cell and 39 | graph node names. 40 | } 41 | \description{ 42 | Choose cells along the path of a principal graph 43 | } 44 | -------------------------------------------------------------------------------- /man/partitions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{partitions} 4 | \alias{partitions} 5 | \title{Generic to extract partitions from CDS object} 6 | \usage{ 7 | partitions(x, reduction_method = "UMAP") 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{reduction_method}{Reduced dimension to partitions clusters for.} 13 | } 14 | \value{ 15 | Partitions. 16 | } 17 | \description{ 18 | Generic to extract partitions from CDS object 19 | } 20 | \examples{ 21 | \donttest{ 22 | cell_metadata <- readRDS(system.file('extdata', 23 | 'worm_embryo/worm_embryo_coldata.rds', 24 | package='monocle3')) 25 | gene_metadata <- readRDS(system.file('extdata', 26 | 'worm_embryo/worm_embryo_rowdata.rds', 27 | package='monocle3')) 28 | expression_matrix <- readRDS(system.file('extdata', 29 | 'worm_embryo/worm_embryo_expression_matrix.rds', 30 | package='monocle3')) 31 | cds <- new_cell_data_set(expression_data=expression_matrix, 32 | cell_metadata=cell_metadata, 33 | gene_metadata=gene_metadata) 34 | 35 | cds <- preprocess_cds(cds) 36 | cds <- reduce_dimension(cds) 37 | cds <- cluster_cells(cds) 38 | partitions_factors <- partitions(cds, "UMAP") 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /man/make_cds_nn_index.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nearest_neighbors.R 3 | \name{make_cds_nn_index} 4 | \alias{make_cds_nn_index} 5 | \title{Make and store a nearest neighbor index in the cell_data_set.} 6 | \usage{ 7 | make_cds_nn_index( 8 | cds, 9 | reduction_method = c("UMAP", "PCA", "LSI", "Aligned", "tSNE"), 10 | nn_control = list(), 11 | verbose = FALSE 12 | ) 13 | } 14 | \arguments{ 15 | \item{cds}{a cell_data_set with the reduced dimension matrix from 16 | which to make the nearest neighbor index and with which the index 17 | is stored.} 18 | 19 | \item{reduction_method}{a string giving the reduced dimension matrix 20 | to use for making the nn_index nearest neighbor index. 21 | Note: distances in tSNE space reflect spatial differences poorly 22 | so using nearest neighbors with it may be meaningless.} 23 | 24 | \item{nn_control}{a list of parameters to use for making the nearest 25 | neighbor index. See the set_nn_control help for details.} 26 | 27 | \item{verbose}{a boolean indicating whether to emit verbose output.} 28 | } 29 | \value{ 30 | a cell_data_set with the stored index. 31 | } 32 | \description{ 33 | Make a nearest neighbor index from the specified 34 | reduction_method matrix in the cell_data_set using either the 35 | default nearest neighbor method or the method specified in the 36 | nn_control list parameter, and store the index in the 37 | cell_data_set. This function returns a cell_data_set. 38 | } 39 | \examples{ 40 | \donttest{ 41 | cds <- load_a549() 42 | cds <- preprocess_cds(cds) 43 | cds <- make_cds_nn_index(cds, 'PCA') 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /tests/testdata/cr2.0/outs/filtered_gene_bc_matrices/hg19/barcodes.tsv: -------------------------------------------------------------------------------- 1 | ATGCCAGAACGACT-1 2 | CATGGCCTGTGCAT-1 3 | GAACCTGATGAACC-1 4 | TGACTGGATTCTCA-1 5 | AGTCAGACTGCACA-1 6 | TCTGATACACGTGT-1 7 | TGGTATCTAAACAG-1 8 | GCAGCTCTGTTTCT-1 9 | GATATAACACGCAT-1 10 | AATGTTGACAGTCA-1 11 | AGGTCATGAGTGTC-1 12 | AGAGATGATCTCGC-1 13 | GGGTAACTCTAGTG-1 14 | CATGAGACACGGGA-1 15 | TACGCCACTCCGAA-1 16 | CTAAACCTGTGCAT-1 17 | GTAAGCACTCATTC-1 18 | TTGGTACTGAATCC-1 19 | CATCATACGGAGCA-1 20 | TACATCACGCTAAC-1 21 | TTACCATGAATCGC-1 22 | ATAGGAGAAACAGA-1 23 | GCGCACGACTTTAC-1 24 | ACTCGCACGAAAGT-1 25 | ATTACCTGCCTTAT-1 26 | CCCAACTGCAATCG-1 27 | AAATTCGAATCACG-1 28 | CCATCCGATTCGCC-1 29 | TCCACTCTGAGCTT-1 30 | CATCAGGATGCACA-1 31 | CTAAACCTCTGACA-1 32 | GATAGAGAAGGGTG-1 33 | CTAACGGAACCGAT-1 34 | AGATATACCCGTAA-1 35 | TACTCTGAATCGAC-1 36 | GCGCATCTTGCTCC-1 37 | GTTGACGATATCGG-1 38 | ACAGGTACTGGTGT-1 39 | GGCATATGCTTATC-1 40 | CATTACACCAACTG-1 41 | TAGGGACTGAACTC-1 42 | GCTCCATGAGAAGT-1 43 | TACAATGATGCTAG-1 44 | CTTCATGACCGAAT-1 45 | CTGCCAACAGGAGC-1 46 | TTGCATTGAGCTAC-1 47 | AAGCAAGAGCTTAG-1 48 | CGGCACGAACTCAG-1 49 | GGTGGAGATTACTC-1 50 | GGCCGATGTACTCT-1 51 | CGTAGCCTGTATGC-1 52 | TGAGCTGAATGCTG-1 53 | CCTATAACGAGACG-1 54 | ATAAGTTGGTACGT-1 55 | AAGCGACTTTGACG-1 56 | ACCAGTGAATACCG-1 57 | ATTGCACTTGCTTT-1 58 | CTAGGTGATGGTTG-1 59 | GCACTAGACCTTTA-1 60 | CATGCGCTAGTCAC-1 61 | TTGAGGACTACGCA-1 62 | ATACCACTCTAAGC-1 63 | CATATAGACTAAGC-1 64 | TTTAGCTGTACTCT-1 65 | GACATTCTCCACCT-1 66 | ACGTGATGCCATGA-1 67 | ATTGTAGATTCCCG-1 68 | GATAGAGATCACGA-1 69 | AATGCGTGGACGGA-1 70 | GCGTAAACACGGTT-1 71 | ATTCAGCTCATTGG-1 72 | GGCATATGGGGAGT-1 73 | ATCATCTGACACCA-1 74 | GTCATACTTCGCCT-1 75 | TTACGTACGTTCAG-1 76 | GAGTTGTGGTAGCT-1 77 | GACGCTCTCTCTCG-1 78 | AGTCTTACTTCGGA-1 79 | GGAACACTTCAGAC-1 80 | CTTGATTGATCTTC-1 81 | -------------------------------------------------------------------------------- /man/plot_cells_per_sample_and_perturbation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_cells_per_sample_and_perturbation} 4 | \alias{plot_cells_per_sample_and_perturbation} 5 | \title{Make a boxplot of the number of cells per sample, with each perturbation as a separate box. Optionally facet by a second value.} 6 | \usage{ 7 | plot_cells_per_sample_and_perturbation( 8 | cds, 9 | perturbation_col = "perturbation", 10 | count_per_sample_col = "count_per_embryo", 11 | zscore = FALSE, 12 | cutoff = NULL, 13 | facet_by = NULL, 14 | color_palette = NULL, 15 | yticks = NULL 16 | ) 17 | } 18 | \arguments{ 19 | \item{cds}{A cell_data_set for plotting.} 20 | 21 | \item{perturbation_col}{How to group the cells for the plot. Must be a column of the colData.} 22 | 23 | \item{count_per_sample_col}{Which column of the colData to put in the boxplots.} 24 | 25 | \item{zscore}{logical value indicating whether to z-score counts before plotting. If \code{TRUE}, then the values in \code{count_per_sample_col} are grouped by the \code{perturbation_col} and z-scored.} 26 | 27 | \item{cutoff}{The minimum number of cells per sample, drawn as a horizontal line. If \code{zscore == TRUE} then this corresponds to the absolute value of the z-score cutoff, and two horizontal lines are drawn.} 28 | 29 | \item{facet_by}{Facet the plot by this column of the colData. Each unique value is its own facet.} 30 | 31 | \item{color_palette}{List of colors to color perturbation groups. Default is NULL. When NULL, use a default set.} 32 | 33 | \item{yticks}{List of numeric values to put on the y-axis ticks.} 34 | } 35 | \value{ 36 | A ggplot2 object. 37 | } 38 | \description{ 39 | Make a boxplot of the number of cells per sample, with each perturbation as a separate box. Optionally facet by a second value. 40 | } 41 | -------------------------------------------------------------------------------- /man/principal_graph.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{principal_graph} 4 | \alias{principal_graph} 5 | \title{Generic to extract principal graph from CDS} 6 | \usage{ 7 | principal_graph(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | Principle graph. 14 | } 15 | \description{ 16 | Generic to extract principal graph from CDS 17 | } 18 | \examples{ 19 | \donttest{ 20 | cell_metadata <- readRDS(system.file('extdata', 21 | 'worm_embryo/worm_embryo_coldata.rds', 22 | package='monocle3')) 23 | gene_metadata <- readRDS(system.file('extdata', 24 | 'worm_embryo/worm_embryo_rowdata.rds', 25 | package='monocle3')) 26 | expression_matrix <- readRDS(system.file('extdata', 27 | 'worm_embryo/worm_embryo_expression_matrix.rds', 28 | package='monocle3')) 29 | 30 | cds <- new_cell_data_set(expression_data=expression_matrix, 31 | cell_metadata=cell_metadata, 32 | gene_metadata=gene_metadata) 33 | 34 | cds <- preprocess_cds(cds) 35 | cds <- align_cds(cds, alignment_group = 36 | "batch", residual_model_formula_str = "~ bg.300.loading + 37 | bg.400.loading + bg.500.1.loading + bg.500.2.loading + 38 | bg.r17.loading + bg.b01.loading + bg.b02.loading") 39 | cds <- reduce_dimension(cds) 40 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 41 | cds <- cluster_cells(cds) 42 | cds <- learn_graph(cds) 43 | pr_gr <- principal_graph(cds) 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /tests/testthat/test-find_markers.R: -------------------------------------------------------------------------------- 1 | context("test-find_markers") 2 | 3 | chk <- Sys.getenv("_R_CHECK_LIMIT_CORES_", "") 4 | 5 | # top_markers(..., cores=8) earlier but devtools::check() fails because cores is too large. 6 | # see https://stackoverflow.com/questions/50571325/r-cran-check-fail-when-using-parallel-functions 7 | # Rather than use parallel::detectCores(), which detects threads rather than cores, may 8 | # may call for too many cores under some circumstances? 9 | if (nzchar(chk) && chk == "TRUE") { 10 | # use 2 cores in CRAN/Travis/AppVeyor 11 | num_cores <- 2L 12 | } else { 13 | # use all cores in devtools::test() 14 | num_cores <- parallel::detectCores() 15 | } 16 | 17 | library(dplyr) 18 | set.seed(1000) 19 | cds <- load_a549() 20 | assigned_type_marker_test_res = top_markers(cds, 21 | group_cells_by="top_oligo", 22 | reference_cells=1000, 23 | cores=num_cores) 24 | 25 | garnett_markers <- assigned_type_marker_test_res %>% 26 | filter(marker_test_p_value < 0.01 & specificity >= 0.5) %>% 27 | group_by(cell_group) %>% 28 | top_n(5, marker_score) 29 | 30 | 31 | test_that("generate_garnett_marker_file_works", { 32 | temp <- tempdir() 33 | generate_garnett_marker_file(garnett_markers, file=paste0(temp,"/marker_file.txt")) 34 | marker <- readLines(paste0(temp,"/marker_file.txt")) 35 | expect_equal(length(marker), 42) 36 | expect_equal(marker[1], "> Cell type Dex_0_AD04") 37 | 38 | garnett_markers$cell_group[1] <- "test_(_:_)_#_,_>" 39 | expect_warning(generate_garnett_marker_file(garnett_markers, file=paste0(temp,"/marker_file.txt"))) 40 | marker <- readLines(paste0(temp,"/marker_file.txt")) 41 | expect_equal(length(marker), 45) 42 | expect_equal(marker[1], "> Cell type test_._._._._._.") 43 | unlink(temp) 44 | }) 45 | -------------------------------------------------------------------------------- /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | customized 2 | knitr 3 | stylesheet 4 | YAML 5 | ACTA 6 | CCNB 7 | cds 8 | colData 9 | ggplot 10 | logarithmically 11 | ncol 12 | nrow 13 | rowData 14 | roxygen 15 | untransformed 16 | al 17 | AML 18 | ArXiv 19 | barcodes 20 | biclustering 21 | Bornholdt's 22 | cellranger 23 | centroid 24 | centroids 25 | CRISPR 26 | dicriminative 27 | doi 28 | Erdös 29 | esApply 30 | Etienne 31 | Garnett 32 | Geary's 33 | ggrastr 34 | Guillaume 35 | Healy 36 | https 37 | igraph 38 | iterable 39 | Jaccard 40 | Jenson 41 | jitter 42 | Laio 43 | Lambiotte 44 | Lanczos 45 | Lefebvre 46 | limma 47 | lmFit 48 | loadings 49 | Loup 50 | Louvain 51 | LSI 52 | Maaten 53 | McInnes 54 | Mech 55 | modularity 56 | plotly 57 | preprocess 58 | Preprocess 59 | pseudocount 60 | pseudotime 61 | quasipoisson 62 | rastered 63 | Reichardt 64 | Renaud 65 | Rényi 66 | SimpleList 67 | SingleCellExperiment 68 | sparseMatrix 69 | superclusters 70 | tibble 71 | Tibble 72 | tSNE 73 | UMAP 74 | UMI 75 | VGAM 76 | agg 77 | CPM 78 | CPMVertexPartition 79 | der 80 | discriminative 81 | DxN 82 | et 83 | extdata 84 | vtraag 85 | uwot 86 | SurpriseVertexPartition 87 | tf 88 | idf 89 | SignificanceVertexPartition 90 | RBERVertexPartition 91 | RBConfigurationVertexPartition 92 | ModularityVertexPartition 93 | SNE 94 | SGD 95 | sdev 96 | repmat 97 | prcomp 98 | param 99 | NxM 100 | mtx 101 | mc 102 | Laurens 103 | reducedDims 104 | objs 105 | num 106 | nb 107 | matlab 108 | louvain 109 | kNN 110 | knn 111 | iter 112 | hg 113 | github 114 | diag 115 | formulization 116 | ATL 117 | Batchelor 118 | Biotechnol 119 | CDSs 120 | Eck 121 | Haghverdi 122 | JC 123 | Lun 124 | Marioni 125 | Traag 126 | Viridis 127 | Waltman 128 | garnett 129 | leiden 130 | leidenbase 131 | nbt 132 | ncenter 133 | str 134 | residual_model_formula_str 135 | MNNCorrect 136 | pre 137 | reticulate 138 | -------------------------------------------------------------------------------- /tests/testthat/test-compare_models.R: -------------------------------------------------------------------------------- 1 | context("compare_models") 2 | cds <- load_a549() 3 | 4 | test_that("compare_models() correctly deems NB better than Poisson",{ 5 | test_cds = cds[rowData(cds)$gene_short_name == "ANGPTL4",] 6 | zinb_cds = test_cds 7 | zinb_fit = fit_models(zinb_cds, expression_family = "zinegbinomial", model_formula_str = "~log_dose") 8 | 9 | zipoisson_cds = test_cds 10 | zipoisson_fit = fit_models(zipoisson_cds,expression_family = "zipoisson", model_formula_str = "~log_dose") 11 | 12 | nb_cds = test_cds 13 | nb_fit = fit_models(nb_cds, model_formula_str = "~log_dose", expression_family = "negbinomial") 14 | nb_reduced_fit = fit_models(nb_cds, model_formula_str = "~1", expression_family = "negbinomial") 15 | nb_comparison = suppressWarnings(compare_models(nb_fit, nb_reduced_fit)) 16 | expect_equal(nb_comparison$p_value[1], 0.0000228, tolerance=1e-3) 17 | 18 | nb_fit = fit_models(nb_cds, model_formula_str = "~log_dose", clean_model = FALSE, expression_family = "negbinomial") 19 | nb_reduced_fit = fit_models(nb_cds, model_formula_str = "~1", clean_model = FALSE, expression_family = "negbinomial") 20 | require("lmtest") # TODO: skip the test below if lmtest isn't available 21 | lmtest_lrt_pval = lmtest::lrtest(nb_fit$model[[1]], nb_reduced_fit$model[[1]])[2,5] 22 | expect_equal(nb_comparison$p_value[1], lmtest_lrt_pval) 23 | 24 | skip("currently failing") 25 | nb_vs_zipoisson_comparison = compare_models(nb_fit, zipoisson_fit) 26 | # The function below should return NA, as you can't compare a zipoisson to a negbinomial via lrt: 27 | expect_equal(nb_vs_zipoisson_comparison$p_value[1], NA_real_) 28 | 29 | zinb_vs_zipoisson_comparison = compare_models(zinb_fit, zipoisson_fit) 30 | # The function below should return NA, as you can't compare a zipoisson to a zinegbinomial via lrt: 31 | expect_equal(zinb_vs_zipoisson_comparison$p_value[1], NA_real_) 32 | }) 33 | 34 | -------------------------------------------------------------------------------- /man/principal_graph_aux.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{principal_graph_aux} 4 | \alias{principal_graph_aux} 5 | \title{Generic to extract principal graph auxiliary information from CDS} 6 | \usage{ 7 | principal_graph_aux(x) 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | } 12 | \value{ 13 | Principal graph auxiliary information. 14 | } 15 | \description{ 16 | Generic to extract principal graph auxiliary information from CDS 17 | } 18 | \examples{ 19 | \donttest{ 20 | cell_metadata <- readRDS(system.file('extdata', 21 | 'worm_embryo/worm_embryo_coldata.rds', 22 | package='monocle3')) 23 | gene_metadata <- readRDS(system.file('extdata', 24 | 'worm_embryo/worm_embryo_rowdata.rds', 25 | package='monocle3')) 26 | expression_matrix <- readRDS(system.file('extdata', 27 | 'worm_embryo/worm_embryo_expression_matrix.rds', 28 | package='monocle3')) 29 | 30 | cds <- new_cell_data_set(expression_data=expression_matrix, 31 | cell_metadata=cell_metadata, 32 | gene_metadata=gene_metadata) 33 | 34 | cds <- preprocess_cds(cds) 35 | cds <- align_cds(cds, alignment_group = 36 | "batch", residual_model_formula_str = "~ bg.300.loading + 37 | bg.400.loading + bg.500.1.loading + bg.500.2.loading + 38 | bg.r17.loading + bg.b01.loading + bg.b02.loading") 39 | cds <- reduce_dimension(cds) 40 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 41 | cds <- cluster_cells(cds) 42 | cds <- learn_graph(cds) 43 | pr_gr_aux <- principal_graph_aux(cds) 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/RcppExports.cpp: -------------------------------------------------------------------------------- 1 | // Generated by using Rcpp::compileAttributes() -> do not edit by hand 2 | // Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 3 | 4 | #include 5 | 6 | using namespace Rcpp; 7 | 8 | #ifdef RCPP_USE_GLOBAL_ROSTREAM 9 | Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); 10 | Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); 11 | #endif 12 | 13 | // jaccard_coeff 14 | NumericMatrix jaccard_coeff(SEXP R_idx, SEXP R_weight); 15 | RcppExport SEXP _monocle3_jaccard_coeff(SEXP R_idxSEXP, SEXP R_weightSEXP) { 16 | BEGIN_RCPP 17 | Rcpp::RObject rcpp_result_gen; 18 | Rcpp::RNGScope rcpp_rngScope_gen; 19 | Rcpp::traits::input_parameter< SEXP >::type R_idx(R_idxSEXP); 20 | Rcpp::traits::input_parameter< SEXP >::type R_weight(R_weightSEXP); 21 | rcpp_result_gen = Rcpp::wrap(jaccard_coeff(R_idx, R_weight)); 22 | return rcpp_result_gen; 23 | END_RCPP 24 | } 25 | // pnorm_over_mat 26 | NumericMatrix pnorm_over_mat(SEXP R_num_links_ij, SEXP R_var_null_num_links); 27 | RcppExport SEXP _monocle3_pnorm_over_mat(SEXP R_num_links_ijSEXP, SEXP R_var_null_num_linksSEXP) { 28 | BEGIN_RCPP 29 | Rcpp::RObject rcpp_result_gen; 30 | Rcpp::RNGScope rcpp_rngScope_gen; 31 | Rcpp::traits::input_parameter< SEXP >::type R_num_links_ij(R_num_links_ijSEXP); 32 | Rcpp::traits::input_parameter< SEXP >::type R_var_null_num_links(R_var_null_num_linksSEXP); 33 | rcpp_result_gen = Rcpp::wrap(pnorm_over_mat(R_num_links_ij, R_var_null_num_links)); 34 | return rcpp_result_gen; 35 | END_RCPP 36 | } 37 | 38 | static const R_CallMethodDef CallEntries[] = { 39 | {"_monocle3_jaccard_coeff", (DL_FUNC) &_monocle3_jaccard_coeff, 2}, 40 | {"_monocle3_pnorm_over_mat", (DL_FUNC) &_monocle3_pnorm_over_mat, 2}, 41 | {NULL, NULL, 0} 42 | }; 43 | 44 | RcppExport void R_init_monocle3(DllInfo *dll) { 45 | R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); 46 | R_useDynamicSymbols(dll, FALSE); 47 | } 48 | -------------------------------------------------------------------------------- /man/pseudotime.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{pseudotime} 4 | \alias{pseudotime} 5 | \title{Generic to extract pseudotime from CDS object} 6 | \usage{ 7 | pseudotime(x, reduction_method = "UMAP") 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{reduction_method}{Reduced dimension to extract pseudotime for.} 13 | } 14 | \value{ 15 | Pseudotime values. 16 | } 17 | \description{ 18 | Generic to extract pseudotime from CDS object 19 | } 20 | \examples{ 21 | \donttest{ 22 | cell_metadata <- readRDS(system.file('extdata', 23 | 'worm_embryo/worm_embryo_coldata.rds', 24 | package='monocle3')) 25 | gene_metadata <- readRDS(system.file('extdata', 26 | 'worm_embryo/worm_embryo_rowdata.rds', 27 | package='monocle3')) 28 | expression_matrix <- readRDS(system.file('extdata', 29 | 'worm_embryo/worm_embryo_expression_matrix.rds', 30 | package='monocle3')) 31 | 32 | cds <- new_cell_data_set(expression_data=expression_matrix, 33 | cell_metadata=cell_metadata, 34 | gene_metadata=gene_metadata) 35 | 36 | cds <- preprocess_cds(cds, num_dim=50) 37 | cds <- align_cds(cds, alignment_group = "batch", 38 | residual_model_formula_str = "~ bg.300.loading + bg.400.loading + 39 | bg.500.1.loading + bg.500.2.loading + bg.r17.loading + bg.b01.loading + 40 | bg.b02.loading") 41 | cds <- reduce_dimension(cds) 42 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 43 | cds <- cluster_cells(cds) 44 | cds <- learn_graph(cds) 45 | cds <- order_cells(cds,root_pr_nodes='Y_27') 46 | ps_tim <- pseudotime(cds) 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /man/principal_graph-set.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{principal_graph<-} 4 | \alias{principal_graph<-} 5 | \title{Generic to set principal graph to CDS} 6 | \usage{ 7 | principal_graph(x) <- value 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{value}{A principal graph object.} 13 | } 14 | \value{ 15 | x. 16 | } 17 | \description{ 18 | Generic to set principal graph to CDS 19 | } 20 | \examples{ 21 | \donttest{ 22 | cell_metadata <- readRDS(system.file('extdata', 23 | 'worm_embryo/worm_embryo_coldata.rds', 24 | package='monocle3')) 25 | gene_metadata <- readRDS(system.file('extdata', 26 | 'worm_embryo/worm_embryo_rowdata.rds', 27 | package='monocle3')) 28 | expression_matrix <- readRDS(system.file('extdata', 29 | 'worm_embryo/worm_embryo_expression_matrix.rds', 30 | package='monocle3')) 31 | 32 | cds <- new_cell_data_set(expression_data=expression_matrix, 33 | cell_metadata=cell_metadata, 34 | gene_metadata=gene_metadata) 35 | 36 | cds <- preprocess_cds(cds) 37 | cds <- align_cds(cds, alignment_group = 38 | "batch", residual_model_formula_str = "~ bg.300.loading + 39 | bg.400.loading + bg.500.1.loading + bg.500.2.loading + 40 | bg.r17.loading + bg.b01.loading + bg.b02.loading") 41 | cds <- reduce_dimension(cds) 42 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 43 | cds <- cluster_cells(cds) 44 | cds <- learn_graph(cds) 45 | pr_gr <- principal_graph(cds) 46 | principal_graph(cds) <- NULL 47 | principal_graph(cds) <- pr_gr 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /man/new_cell_data_set.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/cell_data_set.R 3 | \name{new_cell_data_set} 4 | \alias{new_cell_data_set} 5 | \title{Create a new cell_data_set object.} 6 | \usage{ 7 | new_cell_data_set( 8 | expression_data, 9 | cell_metadata = NULL, 10 | gene_metadata = NULL, 11 | verbose = FALSE 12 | ) 13 | } 14 | \arguments{ 15 | \item{expression_data}{expression data matrix for an experiment, can be a 16 | sparseMatrix.} 17 | 18 | \item{cell_metadata}{data frame containing attributes of individual cells, 19 | where \code{row.names(cell_metadata) = colnames(expression_data)}.} 20 | 21 | \item{gene_metadata}{data frame containing attributes of features 22 | (e.g. genes), where 23 | \code{row.names(gene_metadata) = row.names(expression_data)}.} 24 | 25 | \item{verbose}{a logical value that determines whether or not the 26 | function writes diagnostic information.} 27 | } 28 | \value{ 29 | a new cell_data_set object 30 | } 31 | \description{ 32 | Create a new cell_data_set object. 33 | } 34 | \examples{ 35 | small_a549_colData_df <- readRDS(system.file("extdata", 36 | "small_a549_dex_pdata.rda", 37 | package = "monocle3")) 38 | small_a549_rowData_df <- readRDS(system.file("extdata", 39 | "small_a549_dex_fdata.rda", 40 | package = "monocle3")) 41 | small_a549_exprs <- readRDS(system.file("extdata", 42 | "small_a549_dex_exprs.rda", 43 | package = "monocle3")) 44 | small_a549_exprs <- small_a549_exprs[,row.names(small_a549_colData_df)] 45 | 46 | cds <- new_cell_data_set(expression_data = small_a549_exprs, 47 | cell_metadata = small_a549_colData_df, 48 | gene_metadata = small_a549_rowData_df) 49 | 50 | } 51 | -------------------------------------------------------------------------------- /inst/louvain.py: -------------------------------------------------------------------------------- 1 | def louvain(i, j, val, dim, partition_method, initial_membership, weights, resolution, node_sizes, seed, verbose): 2 | import louvain 3 | import igraph as ig 4 | import numpy 5 | from scipy.sparse import csc_matrix 6 | data = csc_matrix((val, (i, j)), shape = dim) 7 | # vcount = max(data.shape) 8 | sources, targets = data.nonzero() 9 | edgelist = zip(sources.tolist(), targets.tolist()) 10 | G = ig.Graph(edges = list(edgelist)) 11 | 12 | # G = ig.Graph.Adjacency(data.tolist()) 13 | 14 | if partition_method == 'ModularityVertexPartition': 15 | partition = louvain.CPMVertexPartition(G, initial_membership = initial_membership, weights = weights) 16 | elif partition_method == 'RBConfigurationVertexPartition': 17 | partition = louvain.CPMVertexPartition(G, initial_membership = initial_membership, weights = weights, resolution_parameter = resolution) 18 | elif partition_method == 'RBERVertexPartition': 19 | partition = louvain.CPMVertexPartition(G, initial_membership = initial_membership, weights = weights, node_sizes = node_sizes, resolution_parameter = resolution) 20 | elif partition_method == 'CPMVertexPartition': 21 | partition = louvain.CPMVertexPartition(G, initial_membership = initial_membership, weights = weights, node_sizes = node_sizes, resolution_parameter = resolution) 22 | elif partition_method == 'SignificanceVertexPartition': 23 | partition = louvain.CPMVertexPartition(G, initial_membership = initial_membership, node_sizes = node_sizes) 24 | elif partition_method == 'SurpriseVertexPartition': 25 | partition = louvain.CPMVertexPartition(G, initial_membership = initial_membership, weights = weights, node_sizes = node_sizes) 26 | else: 27 | raise ValueError('partition_method ' + partition_method + ' is NOT supported.') 28 | 29 | if seed != None: 30 | louvain.set_rng_seed(seed) 31 | 32 | optimiser = louvain.Optimiser() 33 | diff = optimiser.optimise_partition(partition) 34 | 35 | # ig.plot(partition) 36 | return partition 37 | -------------------------------------------------------------------------------- /man/search_nn_index.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nearest_neighbors.R 3 | \name{search_nn_index} 4 | \alias{search_nn_index} 5 | \title{Search a nearest neighbor index.} 6 | \usage{ 7 | search_nn_index( 8 | query_matrix, 9 | nn_index, 10 | k = 25, 11 | nn_control = list(), 12 | verbose = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{query_matrix}{a reduced dimension matrix used to find the 17 | nearest neighbors in the index nn_index.} 18 | 19 | \item{nn_index}{a nearest_neighbor index.} 20 | 21 | \item{k}{an integer for the number of nearest neighbors to return for 22 | each cell. Default is 25.} 23 | 24 | \item{nn_control}{a list of parameters used to search the nearest 25 | neighbor index. See the set_nn_control help for details. Note: the 26 | default annoy search_k parameter value is set to the default value 27 | of 2 * n_trees * k. It does not know the value of n_trees that was 28 | used to build the annoy index so if a non-default n_trees value 29 | was used to build the index, you may need to set search_k in 30 | nn_control list when you run search_nn_index.} 31 | 32 | \item{verbose}{a boolean indicating whether to emit verbose output.} 33 | } 34 | \value{ 35 | a list list(nn.idx, nn.dists) where nn.idx is 36 | a matrix of nearest neighbor indices and nn.dists is a matrix of 37 | the distance between the index given by the row number and the index 38 | given in nn.idx. If the same reduced dim matrix is used to make the 39 | index and search the index, the index given by the row number should 40 | be in the row, usually in the first column. 41 | } 42 | \description{ 43 | Search a nearest neighbor index for cells near 44 | those in the query_matrix. 45 | } 46 | \examples{ 47 | \donttest{ 48 | cds <- load_a549() 49 | cds <- preprocess_cds(cds) 50 | nn_index <- make_nn_index(SingleCellExperiment::reducedDims(cds)[['PCA']]) 51 | nn_res <- search_nn_index(SingleCellExperiment::reducedDims(cds)[['PCA']], nn_index, 10) 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /tests/testthat/test-cluster_genes.R: -------------------------------------------------------------------------------- 1 | context("test-cluster_genes") 2 | 3 | test_that('test cluster_genes', { 4 | cds <- monocle3:::load_worm_embryo() 5 | set.seed(42) 6 | # 7 | afb_cells <- rownames(colData(cds)[!is.na(colData(cds)$cell.type)&colData(cds)$cell.type=='AFD',]) 8 | afb_cds <- cds[,afb_cells] 9 | 10 | afb_cds <- preprocess_cds(afb_cds, num_dim = 100) 11 | afb_cds <- align_cds(afb_cds, alignment_group='batch', residual_model_formula_str = "~ bg.300.loading + bg.400.loading + bg.500.1.loading + bg.500.2.loading + bg.r17.loading + bg.b01.loading + bg.b02.loading") 12 | afb_cds <- reduce_dimension(afb_cds, umap.fast_sgd=FALSE, cores=1) 13 | afb_cds <- cluster_cells(afb_cds) 14 | afb_cds <- learn_graph(afb_cds, learn_graph_control=list(ncenter=1000), close_loop=TRUE) 15 | # 16 | pr_graph_test_res <- graph_test(afb_cds) 17 | pr_deg_ids <- subset(pr_graph_test_res, q_value < 0.05)$id 18 | gene_module_df <- find_gene_modules(afb_cds[pr_deg_ids,], resolution=1e-2) 19 | cell_group_df <- tibble::tibble(cell=row.names(colData(afb_cds)), 20 | cell_group=partitions(afb_cds)[colnames(afb_cds)]) 21 | agg_mat <- aggregate_gene_expression(afb_cds, gene_module_df, cell_group_df) 22 | 23 | # gene_cluster_df = monocle3:::cluster_genes(test_cds[pr_deg_ids,], resolution=0.001) 24 | # 25 | #text_df <- gene_cluster_df %>% dplyr::group_by(cluster) %>% dplyr::summarize(text_x = stats::median(x = dim_1), 26 | # text_y = stats::median(x = dim_2)) 27 | # ggplot2::qplot(dim_1, dim_2, color=cluster, data=gene_cluster_df) + 28 | # ggplot2::geom_text(data=text_df, mapping = ggplot2::aes_string(x = "text_x", y = "text_y", label = "cluster"), color=I("black"), size = 4) 29 | # png("module_graph.png", res=600, width=8, height=8, units="in") 30 | # monocle3:::plot_cells(test_cds, genes=gene_cluster_df, cell_size=0.5, show_backbone=FALSE, label_branch_points=FALSE, label_leaves=FALSE, label_roots=FALSE) 31 | # dev.off() 32 | } ) 33 | -------------------------------------------------------------------------------- /man/principal_graph-set-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{principal_graph<-,cell_data_set-method} 4 | \alias{principal_graph<-,cell_data_set-method} 5 | \title{Generic to set principal graph to CDS} 6 | \usage{ 7 | \S4method{principal_graph}{cell_data_set}(x) <- value 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{value}{A principal graph object.} 13 | } 14 | \value{ 15 | x. 16 | } 17 | \description{ 18 | Generic to set principal graph to CDS 19 | } 20 | \examples{ 21 | \donttest{ 22 | cell_metadata <- readRDS(system.file('extdata', 23 | 'worm_embryo/worm_embryo_coldata.rds', 24 | package='monocle3')) 25 | gene_metadata <- readRDS(system.file('extdata', 26 | 'worm_embryo/worm_embryo_rowdata.rds', 27 | package='monocle3')) 28 | expression_matrix <- readRDS(system.file('extdata', 29 | 'worm_embryo/worm_embryo_expression_matrix.rds', 30 | package='monocle3')) 31 | 32 | cds <- new_cell_data_set(expression_data=expression_matrix, 33 | cell_metadata=cell_metadata, 34 | gene_metadata=gene_metadata) 35 | 36 | cds <- preprocess_cds(cds) 37 | cds <- align_cds(cds, alignment_group = 38 | "batch", residual_model_formula_str = "~ bg.300.loading + 39 | bg.400.loading + bg.500.1.loading + bg.500.2.loading + 40 | bg.r17.loading + bg.b01.loading + bg.b02.loading") 41 | cds <- reduce_dimension(cds) 42 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 43 | cds <- cluster_cells(cds) 44 | cds <- learn_graph(cds) 45 | pr_gr <- principal_graph(cds) 46 | principal_graph(cds) <- NULL 47 | principal_graph(cds) <- pr_gr 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /man/principal_graph_aux-set.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{principal_graph_aux<-} 4 | \alias{principal_graph_aux<-} 5 | \title{Generic to set principal graph auxiliary information into CDS} 6 | \usage{ 7 | principal_graph_aux(x) <- value 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{value}{A S4Vectors::SimpleList of principal graph auxiliary information.} 13 | } 14 | \value{ 15 | x. 16 | } 17 | \description{ 18 | Generic to set principal graph auxiliary information into CDS 19 | } 20 | \examples{ 21 | \donttest{ 22 | cell_metadata <- readRDS(system.file('extdata', 23 | 'worm_embryo/worm_embryo_coldata.rds', 24 | package='monocle3')) 25 | gene_metadata <- readRDS(system.file('extdata', 26 | 'worm_embryo/worm_embryo_rowdata.rds', 27 | package='monocle3')) 28 | expression_matrix <- readRDS(system.file('extdata', 29 | 'worm_embryo/worm_embryo_expression_matrix.rds', 30 | package='monocle3')) 31 | 32 | cds <- new_cell_data_set(expression_data=expression_matrix, 33 | cell_metadata=cell_metadata, 34 | gene_metadata=gene_metadata) 35 | 36 | cds <- preprocess_cds(cds) 37 | cds <- align_cds(cds, alignment_group = 38 | "batch", residual_model_formula_str = "~ bg.300.loading + 39 | bg.400.loading + bg.500.1.loading + bg.500.2.loading + 40 | bg.r17.loading + bg.b01.loading + bg.b02.loading") 41 | cds <- reduce_dimension(cds) 42 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 43 | cds <- cluster_cells(cds) 44 | cds <- learn_graph(cds) 45 | pr_gr_aux <- principal_graph_aux(cds) 46 | principal_graph_aux(cds) <- NULL 47 | principal_graph_aux(cds) <- pr_gr_aux 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /tests/testthat/test-utils.R: -------------------------------------------------------------------------------- 1 | context('test-utils') 2 | 3 | 4 | test_that("multi-core matrix multiply", { 5 | vunitary <- c(-0.10246245699996,0.349218795415387,0.107696065918671,-0.394864658044197,-0.36801741316425,0.535750468230825,0.212298377431117,0.0300448275234934,0.400051268724487,-0.267491020628564,-0.269939641256313,-0.0231580385439236,0.55136436398801,-0.032732849024305,0.531407373267012,-0.0938843482581937,0.118674208755819,0.44510586295317,0.336194959098801,0.0713041321039548,0.4141500858573,-0.279192347887995,0.12974013446896,0.18915818710894,0.149597140266033,0.72894054560801,0.0235870908389973,0.100952582191678,-0.128466753537641,0.341954546900345,0.252466568895385,-0.199078935598188,0.295690938432411,0.232821513518909,-0.00792258544714056,-0.00689400839817557,0.157348180517412,0.0744539438986995,-0.243816203116933,-0.81555548276894,-0.112349913865846,0.367289288643858,0.437864500944886,0.105567383864327,-0.27959115638877,0.0646571574506133,-0.645281939500741,0.18161641939188,-0.33809337664782,0.0597836287461683,-0.755123028567247,-0.17542120935256,-0.220129761192498,0.0196176297956683,0.107412745660028,0.331837791108866,0.115877044324329,0.0715806731378392,-0.445581344243441,-0.106896276039016,-0.262761805584117,-0.24635229665911,-0.0536170573417597,0.640009590212087,-0.203431238976266,0.105580791046781,-0.264291382463053,-0.130396792599892,0.55760324779765,-0.0864494205127029,0.0710113990109368,-0.00698243530774437,-0.220597106295783,-0.305171912826311,0.542330124852501,0.189939064711827,-0.594393984173097,-0.209080487272822,0.140174055594912,-0.32595890853921,0.00167896392364009,0.686917081025424,-0.0154874095106218,0.451153112109484,0.366289539214495,0.105654846509977,0.244355488085003,-0.338707396035591,-0.0667035231217706,-0.0122668921855083,0.156370960721993,0.248318025003313,-0.53681756398136,0.187651696161988,0.0185564812519676,0.00844704736401481,-0.0533948656714075,0.756104672068077,0.0557898800629559,-0.11147435536336) 6 | um <- matrix(vunitary, nrow=10) 7 | 8 | mmc1 <- matrix_multiply_multicore(um, t(um), 1) 9 | expect_equal(mmc1, diag(10)) 10 | mmc2 <- matrix_multiply_multicore(um, t(um), 2) 11 | expect_equal(mmc2, diag(10)) 12 | } ) 13 | 14 | -------------------------------------------------------------------------------- /man/evaluate_fits.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/expr_models.R 3 | \name{evaluate_fits} 4 | \alias{evaluate_fits} 5 | \title{Evaluate fit of model objects.} 6 | \usage{ 7 | evaluate_fits(model_tbl) 8 | } 9 | \arguments{ 10 | \item{model_tbl}{A tibble of model objects, generally output of 11 | \code{\link{fit_models}}.} 12 | } 13 | \value{ 14 | A table with fit information on each gene. 15 | } 16 | \description{ 17 | Evaluate_fits takes a tibble created by the fit_models 18 | function and returns a table that assists with evaluating how well 19 | the model explains the gene expression data. 20 | } 21 | \examples{ 22 | \donttest{ 23 | cell_metadata <- readRDS(system.file('extdata', 24 | 'worm_embryo/worm_embryo_coldata.rds', 25 | package='monocle3')) 26 | gene_metadata <- readRDS(system.file('extdata', 27 | 'worm_embryo/worm_embryo_rowdata.rds', 28 | package='monocle3')) 29 | expression_matrix <- readRDS(system.file('extdata', 30 | 'worm_embryo/worm_embryo_expression_matrix.rds', 31 | package='monocle3')) 32 | 33 | cds <- new_cell_data_set(expression_data=expression_matrix, 34 | cell_metadata=cell_metadata, 35 | gene_metadata=gene_metadata) 36 | 37 | cds <- preprocess_cds(cds, num_dim=50) 38 | cds <- align_cds(cds, alignment_group = "batch", 39 | residual_model_formula_str = "~ bg.300.loading + bg.400.loading + 40 | bg.500.1.loading + bg.500.2.loading + bg.r17.loading + bg.b01.loading + 41 | bg.b02.loading") 42 | cds <- reduce_dimension(cds) 43 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 44 | cds_subset <- cds[rowData(cds)$gene_short_name \%in\% ciliated_genes,] 45 | gene_fits <- fit_models(cds_subset, model_formula_str = "~embryo.time") 46 | evaluate_fits(gene_fits) 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /man/principal_graph_aux-set-cell_data_set-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generics.R 3 | \name{principal_graph_aux<-,cell_data_set-method} 4 | \alias{principal_graph_aux<-,cell_data_set-method} 5 | \title{Method to set principal graph auxiliary information into CDS} 6 | \usage{ 7 | \S4method{principal_graph_aux}{cell_data_set}(x) <- value 8 | } 9 | \arguments{ 10 | \item{x}{A cell_data_set object.} 11 | 12 | \item{value}{A S4Vectors::SimpleList of principal graph auxiliary information.} 13 | } 14 | \value{ 15 | x. 16 | } 17 | \description{ 18 | Method to set principal graph auxiliary information into CDS 19 | } 20 | \examples{ 21 | \donttest{ 22 | cell_metadata <- readRDS(system.file('extdata', 23 | 'worm_embryo/worm_embryo_coldata.rds', 24 | package='monocle3')) 25 | gene_metadata <- readRDS(system.file('extdata', 26 | 'worm_embryo/worm_embryo_rowdata.rds', 27 | package='monocle3')) 28 | expression_matrix <- readRDS(system.file('extdata', 29 | 'worm_embryo/worm_embryo_expression_matrix.rds', 30 | package='monocle3')) 31 | 32 | cds <- new_cell_data_set(expression_data=expression_matrix, 33 | cell_metadata=cell_metadata, 34 | gene_metadata=gene_metadata) 35 | 36 | cds <- preprocess_cds(cds) 37 | cds <- align_cds(cds, alignment_group = 38 | "batch", residual_model_formula_str = "~ bg.300.loading + 39 | bg.400.loading + bg.500.1.loading + bg.500.2.loading + 40 | bg.r17.loading + bg.b01.loading + bg.b02.loading") 41 | cds <- reduce_dimension(cds) 42 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 43 | cds <- cluster_cells(cds) 44 | cds <- learn_graph(cds) 45 | pr_gr_aux <- principal_graph_aux(cds) 46 | principal_graph_aux(cds) <- NULL 47 | principal_graph_aux(cds) <- pr_gr_aux 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /man/plot_genes_in_pseudotime.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_genes_in_pseudotime} 4 | \alias{plot_genes_in_pseudotime} 5 | \title{Plots expression for one or more genes as a function of pseudotime} 6 | \usage{ 7 | plot_genes_in_pseudotime( 8 | cds_subset, 9 | min_expr = NULL, 10 | cell_size = 0.75, 11 | nrow = NULL, 12 | ncol = 1, 13 | panel_order = NULL, 14 | color_cells_by = "pseudotime", 15 | trend_formula = "~ splines::ns(pseudotime, df=3)", 16 | label_by_short_name = TRUE, 17 | vertical_jitter = NULL, 18 | horizontal_jitter = NULL 19 | ) 20 | } 21 | \arguments{ 22 | \item{cds_subset}{subset cell_data_set including only the genes to be 23 | plotted.} 24 | 25 | \item{min_expr}{the minimum (untransformed) expression level to plot.} 26 | 27 | \item{cell_size}{the size (in points) of each cell used in the plot.} 28 | 29 | \item{nrow}{the number of rows used when laying out the panels for each 30 | gene's expression.} 31 | 32 | \item{ncol}{the number of columns used when laying out the panels for each 33 | gene's expression} 34 | 35 | \item{panel_order}{vector of gene names indicating the order in which genes 36 | should be laid out (left-to-right, top-to-bottom). If 37 | \code{label_by_short_name = TRUE}, use gene_short_name values, otherwise 38 | use feature IDs.} 39 | 40 | \item{color_cells_by}{the cell attribute (e.g. the column of colData(cds)) 41 | to be used to color each cell.} 42 | 43 | \item{trend_formula}{the model formula to be used for fitting the expression 44 | trend over pseudotime.} 45 | 46 | \item{label_by_short_name}{label figure panels by gene_short_name (TRUE) or 47 | feature ID (FALSE).} 48 | 49 | \item{vertical_jitter}{A value passed to ggplot to jitter the points in the 50 | vertical dimension. Prevents overplotting, and is particularly helpful for 51 | rounded transcript count data.} 52 | 53 | \item{horizontal_jitter}{A value passed to ggplot to jitter the points in 54 | the horizontal dimension. Prevents overplotting, and is particularly 55 | helpful for rounded transcript count data.} 56 | } 57 | \value{ 58 | a ggplot2 plot object 59 | } 60 | \description{ 61 | Plots expression for one or more genes as a function of pseudotime 62 | } 63 | -------------------------------------------------------------------------------- /tests/testthat/test-select_cells.R: -------------------------------------------------------------------------------- 1 | context("test-select_cells") 2 | 3 | cds <- load_a549() 4 | 5 | test_that("test choose_graph_segments error messages work", { 6 | expect_error(cds <- choose_graph_segments(cds), 7 | "No dimensionality reduction for UMAP calculated. Please run reduce_dimension with reduction_method = UMAP, cluster_cells and learn_graph before running choose_graph_segments.") 8 | cds <- preprocess_cds(cds) 9 | expect_error(cds <- choose_graph_segments(cds), 10 | "No dimensionality reduction for UMAP calculated. Please run reduce_dimension with reduction_method = UMAP, cluster_cells and learn_graph before running choose_graph_segments.") 11 | cds <- reduce_dimension(cds) 12 | expect_error(cds <- choose_graph_segments(cds), 13 | "No cell clusters for UMAP calculated. Please run cluster_cells with reduction_method = UMAP and run learn_graph before running choose_graph_segments.") 14 | cds <- cluster_cells(cds) 15 | expect_error(cds <- choose_graph_segments(cds), 16 | "No principal graph for UMAP calculated. Please run learn_graph with reduction_method = UMAP before running choose_graph_segments.") 17 | cds <- learn_graph(cds) 18 | expect_error(cds_sub <- choose_graph_segments(cds, starting_pr_node = "Y_4"), 19 | "If not using interactive mode, you must provide ending_pr_nodes.") 20 | expect_error(cds_sub <- choose_graph_segments(cds, ending_pr_nodes = "Y_4"), 21 | "If not using interactive mode, you must provide a starting_pr_node") 22 | }) 23 | 24 | cds <- preprocess_cds(cds) 25 | cds <- reduce_dimension(cds) 26 | cds <- cluster_cells(cds) 27 | cds <- learn_graph(cds) 28 | 29 | test_that("test choose_graph_segments non-interactive works", { 30 | cds_sub <- choose_graph_segments(cds, starting_pr_node = "Y_1", 31 | ending_pr_nodes = "Y_6") 32 | assertthat::are_equal(ncol(cds_sub), 281) 33 | cds_sub <- choose_graph_segments(cds, starting_pr_node = "Y_1", 34 | ending_pr_nodes = c( "Y_3")) 35 | assertthat::are_equal(ncol(cds_sub), 172) 36 | 37 | cds_sub <- choose_graph_segments(cds, starting_pr_node = "Y_3", 38 | ending_pr_nodes = c( "Y_6", "Y_2")) 39 | assertthat::are_equal(ncol(cds_sub), 342) 40 | }) 41 | 42 | -------------------------------------------------------------------------------- /man/coefficient_table.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/expr_models.R 3 | \name{coefficient_table} 4 | \alias{coefficient_table} 5 | \title{Extract coefficient table from a fit_models result.} 6 | \usage{ 7 | coefficient_table(model_tbl) 8 | } 9 | \arguments{ 10 | \item{model_tbl}{A tibble of model objects, generally the output of 11 | \code{\link{fit_models}}.} 12 | } 13 | \value{ 14 | A table of coefficient data for each gene. 15 | } 16 | \description{ 17 | Extracts a table of coefficients from a tibble 18 | containing model objects. It tests whether each coefficient 19 | differs significantly from zero under the Wald test and 20 | adjusts the p-values for multiple hypothesis testing using 21 | the method of Benjamini and Hochberg, placing these 22 | adjusted values in the q-value column. 23 | } 24 | \examples{ 25 | \donttest{ 26 | cell_metadata <- readRDS(system.file('extdata', 27 | 'worm_embryo/worm_embryo_coldata.rds', 28 | package='monocle3')) 29 | gene_metadata <- readRDS(system.file('extdata', 30 | 'worm_embryo/worm_embryo_rowdata.rds', 31 | package='monocle3')) 32 | expression_matrix <- readRDS(system.file('extdata', 33 | 'worm_embryo/worm_embryo_expression_matrix.rds', 34 | package='monocle3')) 35 | 36 | cds <- new_cell_data_set(expression_data=expression_matrix, 37 | cell_metadata=cell_metadata, 38 | gene_metadata=gene_metadata) 39 | 40 | cds <- preprocess_cds(cds, num_dim=50) 41 | cds <- align_cds(cds, alignment_group = "batch", 42 | residual_model_formula_str = "~ bg.300.loading + bg.400.loading + 43 | bg.500.1.loading + bg.500.2.loading + bg.r17.loading + 44 | bg.b01.loading + bg.b02.loading") 45 | cds <- reduce_dimension(cds) 46 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 47 | cds_subset <- cds[rowData(cds)$gene_short_name \%in\% ciliated_genes,] 48 | gene_fits <- fit_models(cds_subset, model_formula_str = "~embryo.time") 49 | fit_coefs <- coefficient_table(gene_fits) 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /man/plot_genes_violin.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_genes_violin} 4 | \alias{plot_genes_violin} 5 | \title{Plot expression for one or more genes as a violin plot} 6 | \usage{ 7 | plot_genes_violin( 8 | cds_subset, 9 | group_cells_by = NULL, 10 | min_expr = 0, 11 | nrow = NULL, 12 | ncol = 1, 13 | panel_order = NULL, 14 | label_by_short_name = TRUE, 15 | normalize = TRUE, 16 | log_scale = TRUE, 17 | pseudocount = 0 18 | ) 19 | } 20 | \arguments{ 21 | \item{cds_subset}{Subset cell_data_set to be plotted.} 22 | 23 | \item{group_cells_by}{NULL of the cell attribute (e.g. the column of 24 | colData(cds)) to group cells by on the horizontal axis. If NULL, all cells 25 | are plotted together.} 26 | 27 | \item{min_expr}{the minimum (untransformed) expression level to be plotted. 28 | Default is 0.} 29 | 30 | \item{nrow}{the number of panels per row in the figure.} 31 | 32 | \item{ncol}{the number of panels per column in the figure.} 33 | 34 | \item{panel_order}{the order in which genes should be laid out 35 | (left-to-right, top-to-bottom). Should be gene_short_name if 36 | \code{label_by_short_name = TRUE} or feature ID if 37 | \code{label_by_short_name = FALSE}.} 38 | 39 | \item{label_by_short_name}{label figure panels by gene_short_name (TRUE) or 40 | feature id (FALSE). Default is TRUE.} 41 | 42 | \item{normalize}{Logical, whether or not to normalize expression by size 43 | factor. Default is TRUE.} 44 | 45 | \item{log_scale}{Logical, whether or not to scale data logarithmically. 46 | Zero count cells are excluded from the plot and median when log_scale 47 | is TRUE. Default is TRUE.} 48 | 49 | \item{pseudocount}{A pseudo-count added to the gene expression. A 50 | pseudocount value greater than 0 is reset to 1. Default is 0.} 51 | } 52 | \value{ 53 | a ggplot2 plot object 54 | } 55 | \description{ 56 | Accepts a subset of a cell_data_set and an attribute to group 57 | cells by, and produces a ggplot2 object that plots the level of expression 58 | for each group of cells. The median value is plotted as a black dot. 59 | } 60 | \examples{ 61 | \donttest{ 62 | cds <- load_a549() 63 | cds_subset <- cds[row.names(subset(rowData(cds), 64 | gene_short_name \%in\% c("ACTA1", "ID1", "CCNB2"))),] 65 | plot_genes_violin(cds_subset, group_cells_by="culture_plate", ncol=2, 66 | min_expr=0.1) 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /man/search_cds_nn_index.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nearest_neighbors.R 3 | \name{search_cds_nn_index} 4 | \alias{search_cds_nn_index} 5 | \title{Search a nearest neighbor index that is stored in 6 | the cds.} 7 | \usage{ 8 | search_cds_nn_index( 9 | query_matrix, 10 | cds, 11 | reduction_method = c("UMAP", "PCA", "LSI", "Aligned", "tSNE"), 12 | k = 25, 13 | nn_control = list(), 14 | verbose = FALSE 15 | ) 16 | } 17 | \arguments{ 18 | \item{query_matrix}{a reduced dimension matrix used to find the 19 | nearest neighbors in the index nn_index.} 20 | 21 | \item{cds}{a cell_data_set in which the nearest neighbor index 22 | is stored.} 23 | 24 | \item{reduction_method}{a string giving the reduced 25 | dimension matrix used to make the nearest neighbor index, and 26 | determines where the index is stored in the cell_data_set. 27 | Note: distances in tSNE space reflect spatial differences poorly 28 | so using nearest neighbors with it may be meaningless.} 29 | 30 | \item{k}{an integer for the number of nearest neighbors to return for 31 | each cell. Default is 25.} 32 | 33 | \item{nn_control}{a list of parameters used to make and search 34 | the nearest neighbors indexes. See the set_nn_control help 35 | for additional details. Note that if nn_control[['search_k']] 36 | is not defined, transfer_cell_labels will try to use 37 | search_k <- 2 * n_trees * k where n_trees is the value used 38 | to build the index. The default metric is cosine for 39 | reduction_methods PCA, LSI, and Aligned, and is euclidean for 40 | reduction_methods tSNE and UMAP.} 41 | 42 | \item{verbose}{a boolean indicating whether to emit verbose output.} 43 | } 44 | \value{ 45 | a list list(nn.idx, nn.dists) where nn.idx is 46 | a matrix of nearest neighbor indices and nn.dists is a matrix of 47 | the distance between the index given by the row number and the index 48 | given in nn.idx. If the same reduced dim matrix is used to make the 49 | index and search the index, the index given by the row number should 50 | be in the row, usually in the first column. 51 | } 52 | \description{ 53 | Search a nearest neighbor index for cells near 54 | those in the query_matrix. 55 | } 56 | \examples{ 57 | \donttest{ 58 | cds <- load_a549() 59 | cds <- preprocess_cds(cds) 60 | cds <- make_cds_nn_index(cds, 'PCA') 61 | nn_res <- search_cds_nn_index(SingleCellExperiment::reducedDims(cds)[['PCA']], cds, 'PCA', 10) 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /man/combine_cds.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils.R 3 | \name{combine_cds} 4 | \alias{combine_cds} 5 | \title{Combine a list of cell_data_set objects} 6 | \usage{ 7 | combine_cds( 8 | cds_list, 9 | keep_all_genes = TRUE, 10 | cell_names_unique = FALSE, 11 | sample_col_name = "sample", 12 | keep_reduced_dims = FALSE, 13 | matrix_control = list(), 14 | verbose = FALSE 15 | ) 16 | } 17 | \arguments{ 18 | \item{cds_list}{List of cds objects to be combined.} 19 | 20 | \item{keep_all_genes}{Logical indicating what to do if there is a mismatch 21 | in the gene sets of the CDSs. If TRUE, all genes are kept and cells from 22 | CDSs missing a given gene will be filled in with zeroes. If FALSE, only 23 | the genes in common among all of the CDSs will be kept. Default is TRUE.} 24 | 25 | \item{cell_names_unique}{Logical indicating whether all of the cell IDs 26 | across all of the CDSs are unique. If FALSE, the CDS name is appended to 27 | each cell ID to prevent collisions. These cell IDs are used as count matrix 28 | column names and colData(cds) row names. Cell names stored in other 29 | cds locations are not modified so you will need to modify them manually 30 | for consistency. Default is FALSE.} 31 | 32 | \item{sample_col_name}{A string to be the column name for the colData column 33 | that indicates which original cds the cell derives from. Default is 34 | "sample".} 35 | 36 | \item{keep_reduced_dims}{Logical indicating whether to keep the reduced 37 | dimension matrices. Do not keep the reduced dimensions unless you know 38 | that the reduced dimensions are the same in each CDS. This is true for 39 | projected data sets, for example. Default is FALSE.} 40 | 41 | \item{matrix_control}{A list used to control how the counts matrix is 42 | is stored in the CDS. By default, combine_cds stores the counts 43 | matrix as an in-memory, sparse (dgCMatrix), unless (a) at least one 44 | of the cdses in cds_list uses a BPCells counts matrix, or 45 | (b) you specify matrix_control=list(matrix_class='BPCells').} 46 | 47 | \item{verbose}{Whether to emit verbose output while running 48 | combine_cds. 49 | Default is FALSE.} 50 | } 51 | \value{ 52 | A combined cell_data_set object. 53 | } 54 | \description{ 55 | This function will combine a list of cell_data_set objects into a new 56 | cell_data_set object. 57 | } 58 | \details{ 59 | If any of the counts matrices is BPCells class, the combined 60 | counts matrix will be BPCells class. 61 | } 62 | -------------------------------------------------------------------------------- /man/plot_cells_3d.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_cells_3d} 4 | \alias{plot_cells_3d} 5 | \title{Plot a dataset and trajectory in 3 dimensions} 6 | \usage{ 7 | plot_cells_3d( 8 | cds, 9 | dims = c(1, 2, 3), 10 | reduction_method = c("UMAP", "tSNE", "PCA", "LSI", "Aligned"), 11 | color_cells_by = "cluster", 12 | genes = NULL, 13 | show_trajectory_graph = TRUE, 14 | trajectory_graph_color = "black", 15 | trajectory_graph_segment_size = 5, 16 | norm_method = c("log", "size_only"), 17 | color_palette = NULL, 18 | color_scale = "Viridis", 19 | cell_size = 25, 20 | alpha = 1, 21 | min_expr = 0.1 22 | ) 23 | } 24 | \arguments{ 25 | \item{cds}{cell_data_set to plot} 26 | 27 | \item{dims}{numeric vector that indicates the dimensions used to create the 28 | 3D plot, by default it is the first three dimensions.} 29 | 30 | \item{reduction_method}{string indicating the reduction method to plot.} 31 | 32 | \item{color_cells_by}{the cell attribute (e.g. the column of colData(cds)) 33 | to map to each cell's color. Default is cluster.} 34 | 35 | \item{genes}{a gene name or gene id to color the plot by.} 36 | 37 | \item{show_trajectory_graph}{a logical used to indicate whether to graph the 38 | principal graph backbone. Default is TRUE.} 39 | 40 | \item{trajectory_graph_color}{the color of graph backbone. Default is black.} 41 | 42 | \item{trajectory_graph_segment_size}{numeric indicating the width of the 43 | graph backbone. Default is 5.} 44 | 45 | \item{norm_method}{string indicating the method used to transform gene 46 | expression when gene markers are provided. Default is "log". "size_only" 47 | is also supported.} 48 | 49 | \item{color_palette}{List of colors to pass to plotly for coloring cells by 50 | categorical variables. Default is NULL. When NULL, plotly uses default 51 | colors.} 52 | 53 | \item{color_scale}{The name of the color scale passed to plotly for coloring 54 | cells by numeric scale. Default is "Viridis".} 55 | 56 | \item{cell_size}{numeric indicating the size of the point to be plotted. 57 | Default is 25.} 58 | 59 | \item{alpha}{numeric indicating the alpha value of the plotted cells. 60 | Default is 1.} 61 | 62 | \item{min_expr}{numeric indicating the minimum marker gene value to be 63 | colored. Default is 0.1.} 64 | } 65 | \value{ 66 | a plotly plot object 67 | } 68 | \description{ 69 | Plot a dataset and trajectory in 3 dimensions 70 | } 71 | \examples{ 72 | \dontrun{ 73 | plot_cells_3d(cds, markers=c("Rbfox3, Neurod1", "Sox2")) 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /vignettes/whbiocvignette.sty: -------------------------------------------------------------------------------- 1 | \NeedsTeXFormat{LaTeX2e} 2 | \ProvidesPackage{whbiocvignette}[2013/02/24 Wolfgang Huber's class for Bioconductor vignettes] 3 | % 4 | % -I would wish to know how to make this work- 5 | %\DeclareOption{pdftitle}{\PassOptionsToPackage{pdftitle}{hyperref}} 6 | %\DeclareOption{pdfauthor}{\PassOptionsToPackage{pdfauthor}{hyperref}} 7 | %\ExecuteOptions{pdftitle,pdfauthor} 8 | %\ProcessOptions 9 | % 10 | \RequirePackage[% 11 | pdfpagelabels,% 12 | plainpages=false,% 13 | pdfborder={0 0 0},% 14 | pdfstartview=FitH,% 15 | bookmarks=true,% 16 | bookmarksnumbered=true,% 17 | bookmarksopen=true,% 18 | linktoc=section,% 19 | linkcolor=BlueViolet,% 20 | citecolor=BlueViolet,% 21 | urlcolor=BlueViolet,% 22 | linkbordercolor={.7 .7 .7}, 23 | citebordercolor={.7 .7 .7}, 24 | urlbordercolor={.7 .7 .7} , 25 | raiselinks]{hyperref} 26 | 27 | % \RequirePackage[usenames,dvipsnames]{xcolor} 28 | \RequirePackage{xcolor} 29 | \RequirePackage[a4paper,left=1.9cm,top=1.9cm,bottom=2.5cm,right=1.9cm,ignoreheadfoot]{geometry} 30 | %\RequirePackage{graphicx} 31 | \RequirePackage{helvet} 32 | \renewcommand{\familydefault}{\sfdefault} 33 | \RequirePackage{cite} 34 | \pagestyle{empty} 35 | % 36 | \RequirePackage{sectsty} 37 | \sectionfont{\sffamily\bfseries\color{RoyalBlue}\sectionrule{0pt}{0pt}{-1ex}{1pt}} 38 | \subsectionfont{\sffamily\bfseries\color{RoyalBlue}} 39 | \subsubsectionfont{\sffamily\bfseries\color{RoyalBlue}} 40 | % 41 | \RequirePackage{fancyhdr} 42 | \pagestyle{fancy} 43 | \fancyhead{} 44 | \fancyfoot{} 45 | \lfoot{}\cfoot{\thetitle}\rfoot{} 46 | \renewcommand{\headrule}{} 47 | % 48 | \RequirePackage{xstring} 49 | % 50 | \RequirePackage{Sweave} 51 | % 52 | \renewcommand{\floatpagefraction}{0.9} 53 | % 54 | \newcommand{\Robject}[1]{\texttt{#1}} 55 | \newcommand{\Rpackage}[1]{\textit{#1}} 56 | \newcommand{\Rclass}[1]{\textit{#1}} 57 | \newcommand{\Rfunction}[1]{{\texttt{#1}}} 58 | % 59 | \newcommand{\comment}[1]{\textsl{\textcolor{Gray}{#1}}} 60 | \newcommand{\fixme}[1]{\textsl{\textcolor{Bittersweet}{Fixme: #1}}} 61 | % 62 | \newcommand{\myincfig}[4]{% 63 | \begin{figure}[htbp] 64 | \begin{center} 65 | \includegraphics[width=#2]{#1} 66 | \caption[#3]{\label{#1}\textbf{#3} #4} 67 | \end{center} 68 | \end{figure} 69 | } 70 | % 71 | \newenvironment{packeditemize}{ 72 | \begin{itemize} 73 | \setlength{\itemsep}{1pt} 74 | \setlength{\parskip}{0pt} 75 | \setlength{\parsep}{0pt} 76 | }{\end{itemize}} 77 | % 78 | \newenvironment{packedenumerate}{ 79 | \begin{enumerate} 80 | \setlength{\itemsep}{1pt} 81 | \setlength{\parskip}{0pt} 82 | \setlength{\parsep}{0pt} 83 | }{\end{enumerate}} 84 | % 85 | \endinput 86 | -------------------------------------------------------------------------------- /man/plot_genes_hybrid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_genes_hybrid} 4 | \alias{plot_genes_hybrid} 5 | \title{Plot expression for one or more genes as a hybrid histogram-interval with 6 | a Sina plot overlay.} 7 | \usage{ 8 | plot_genes_hybrid( 9 | cds_subset, 10 | group_cells_by = NULL, 11 | min_expr = 0, 12 | nrow = NULL, 13 | ncol = 1, 14 | panel_order = NULL, 15 | label_by_short_name = TRUE, 16 | normalize = TRUE, 17 | log_scale = TRUE, 18 | pseudocount = 0 19 | ) 20 | } 21 | \arguments{ 22 | \item{cds_subset}{Subset cell_data_set to be plotted.} 23 | 24 | \item{group_cells_by}{NULL of the cell attribute (e.g. the column of 25 | colData(cds)) to group cells by on the horizontal axis. If NULL, all cells 26 | are plotted together.} 27 | 28 | \item{min_expr}{the minimum (untransformed) expression level to be plotted. 29 | Default is 0.} 30 | 31 | \item{nrow}{the number of panels per row in the figure.} 32 | 33 | \item{ncol}{the number of panels per column in the figure.} 34 | 35 | \item{panel_order}{the order in which genes should be laid out 36 | (left-to-right, top-to-bottom). Should be gene_short_name if 37 | \code{label_by_short_name = TRUE} or feature ID if 38 | \code{label_by_short_name = FALSE}.} 39 | 40 | \item{label_by_short_name}{label figure panels by gene_short_name (TRUE) or 41 | feature id (FALSE). Default is TRUE.} 42 | 43 | \item{normalize}{Logical, whether or not to normalize expression by size 44 | factor. Default is TRUE.} 45 | 46 | \item{log_scale}{Logical, whether or not to scale data logarithmically. 47 | Zero count cells are excluded from the plot, interval, and median 48 | when log_scale is TRUE. Default is TRUE.} 49 | 50 | \item{pseudocount}{A pseudo-count added to the gene expression. A 51 | pseudocount value greater than 0 is reset to 1. Default is 0.} 52 | } 53 | \value{ 54 | a ggplot2 plot object 55 | } 56 | \description{ 57 | Accepts a subset of a cell_data_set and an attribute to group 58 | cells by, and produces a ggplot2 object that plots the level of expression 59 | for each group of cells. The cells appear as red dots in a Sina plot 60 | and the cell distribution appears as a histogram with green bars and 61 | a blue median_qi interval. See help for ggforce::geom_sina and 62 | ggdist::stat_histinterval for additional information. 63 | } 64 | \examples{ 65 | \donttest{ 66 | cds <- load_a549() 67 | cds_subset <- cds[row.names(subset(rowData(cds), 68 | gene_short_name \%in\% c("ACTA1", "ID1", "CCNB2"))),] 69 | plot_genes_hybrid(cds_subset, group_cells_by="culture_plate", ncol=2, 70 | min_expr=0.1) 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /man/reduce_dimension_transform.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/projection.R 3 | \name{reduce_dimension_transform} 4 | \alias{reduce_dimension_transform} 5 | \title{Apply a reduce_dimension transform model to a cell_data_set.} 6 | \usage{ 7 | reduce_dimension_transform( 8 | cds, 9 | preprocess_method = NULL, 10 | reduction_method = c("UMAP"), 11 | verbose = FALSE 12 | ) 13 | } 14 | \arguments{ 15 | \item{cds}{a cell_data_set to be transformed.} 16 | 17 | \item{preprocess_method}{the reduced dimension matrix to be 18 | transformed using the reduction_method transform model. 19 | The default is NULL, which uses the preprocess_method that 20 | was used when the reduce_dimension model was built.} 21 | 22 | \item{reduction_method}{a previously loaded reduce_dimension transform 23 | model that is used to reduce the dimensions of the preprocessed 24 | matrix in the cell_data_set. Only "UMAP" is supported.} 25 | 26 | \item{verbose}{a logical value that determines whether or not the 27 | function writes diagnostic information.} 28 | } 29 | \value{ 30 | a cell_data_set with a transformed 31 | reduced count matrix. 32 | } 33 | \description{ 34 | Applies a previously calculated reduce_dimension 35 | transform model to a new preprocess transformed matrix. For 36 | more information read the help information for 37 | save_transform_models. 38 | } 39 | \examples{ 40 | \dontrun{ 41 | cell_metadata <- readRDS(system.file('extdata', 42 | 'worm_embryo/worm_embryo_coldata.rds', 43 | package='monocle3')) 44 | gene_metadata <- readRDS(system.file('extdata', 45 | 'worm_embryo/worm_embryo_rowdata.rds', 46 | package='monocle3')) 47 | expression_matrix <- readRDS(system.file('extdata', 48 | 'worm_embryo/worm_embryo_expression_matrix.rds', 49 | package='monocle3')) 50 | cds <- new_cell_data_set(expression_data=expression_matrix, 51 | cell_metadata=cell_metadata, 52 | gene_metadata=gene_metadata) 53 | ncell <- nrow(colData(cds)) 54 | cell_sample <- sample(seq(ncell), 2 * ncell / 3) 55 | cell_set <- seq(ncell) \%in\% cell_sample 56 | cds1 <- cds[,cell_set] 57 | cds1 <- preprocess_cds(cds1) 58 | cds1 <- reduce_dimension(cds1) 59 | save_transform_models(cds1, 'tm') 60 | cds2 <- cds[,!cell_set] 61 | cds2 <- load_transform_models(cds2, 'tm') 62 | cds2 <- preprocess_transform(cds2, 'PCA') 63 | cds2 <- reduce_dimension_transform(cds2) 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /tests/testthat/test-cell_data_set.R: -------------------------------------------------------------------------------- 1 | 2 | small_a549_colData_df <- readRDS(system.file("extdata", "small_a549_dex_pdata.rda", package = "monocle3")) 3 | small_a549_rowData_df <- readRDS(system.file("extdata", "small_a549_dex_fdata.rda", package = "monocle3")) 4 | small_a549_exprs <- readRDS(system.file("extdata", "small_a549_dex_exprs.rda", package = "monocle3")) 5 | small_a549_exprs <- small_a549_exprs[,row.names(small_a549_colData_df)] 6 | 7 | 8 | test_that("new_cell_data_set works" ,{ 9 | expect_error(cds <- new_cell_data_set( 10 | expression_data = as.data.frame(as.matrix(small_a549_exprs)), 11 | cell_metadata = small_a549_colData_df, 12 | gene_metadata = small_a549_rowData_df), 13 | "Argument expression_data must be a matrix - either sparse from the Matrix package, dense, or a BPCells matrix") 14 | 15 | expect_warning(cds <- new_cell_data_set(expression_data = small_a549_exprs, 16 | cell_metadata = small_a549_colData_df)) 17 | 18 | expect_error(cds <- new_cell_data_set(expression_data = small_a549_exprs, 19 | cell_metadata = small_a549_colData_df[1:100,], 20 | gene_metadata = small_a549_rowData_df), 21 | "cell_metadata must be NULL or have the same number of rows as columns in expression_data") 22 | 23 | expect_error(cds <- new_cell_data_set(expression_data = small_a549_exprs, 24 | cell_metadata = small_a549_colData_df, 25 | gene_metadata = small_a549_rowData_df[1:100,]), 26 | "gene_metadata must be NULL or have the same number of rows as rows in expression_data") 27 | temp <- small_a549_colData_df 28 | row.names(temp)[1] <- "HP" 29 | expect_error(cds <- new_cell_data_set(expression_data = small_a549_exprs, 30 | cell_metadata = temp, 31 | gene_metadata = small_a549_rowData_df), 32 | "row.names of cell_metadata must be equal to colnames of expression_data") 33 | 34 | temp <- small_a549_rowData_df 35 | row.names(temp)[1] <- "HP" 36 | expect_error(cds <- new_cell_data_set(expression_data = small_a549_exprs, 37 | cell_metadata = small_a549_colData_df, 38 | gene_metadata = temp), 39 | "row.names of gene_metadata must be equal to row.names of expression_data") 40 | cds <- new_cell_data_set(expression_data = small_a549_exprs, 41 | cell_metadata = small_a549_colData_df, 42 | gene_metadata = small_a549_rowData_df) 43 | expect_is(cds, "cell_data_set") 44 | 45 | }) 46 | 47 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^LICENSE\.md$ 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | ^.travis.yml 5 | ^.github 6 | ^atac_cds_bge.rds 7 | ^atac_transform_models_20210927 8 | ^batch.R 9 | ^cao_l2.cluster.rds 10 | ^cao_l2.load.rds 11 | ^cao_l2.preprocess.rds 12 | ^data_sets 13 | ^documentation_needed 14 | ^examples 15 | ^examples.20211221.txt 16 | ^expr.mtx 17 | ^gap16_ref_models 18 | ^gene_module_df_dev_length.txt 19 | ^gene_module_df_unit_length.txt 20 | ^hubmap.atac-seq.w135.pancreas.s1.20210927.rds 21 | ^hubmap.atac-seq.w136.pancreas.s1.20210927.rds 22 | ^hubmap.atac-seq.w136.pancreas.s2.20210927.rds 23 | ^jennifer_mods 24 | ^mo 25 | ^module_bin2d.pdf 26 | ^module_bin2d.ps 27 | ^monocle3_objects 28 | ^monocle3.Rproj 29 | ^monocle3.test_lsi_numi_clean.txt 30 | ^monocle_objects.01 31 | ^mutant.cell_type_sub.join.csv 32 | ^mutant.cell_type_sub.join.ods 33 | ^mutant.fix_nas2.cell_type_sub.txt 34 | ^mutant.fix_nas.cell_type_sub.csv 35 | ^mutant.fix_nas.cell_type_sub.txt 36 | ^mutant.maddys.cell_type_sub.txt 37 | ^mutant.modified.cell_type_sub.txt 38 | ^mutant.orig.cell_type_sub.txt 39 | ^mutant.remodified2.cell_type_sub.txt 40 | ^mutant.remodified.cell_type_sub.txt 41 | ^my_cds_for_lsi.rds 42 | ^notes.bad_loop_ranges.20220211.txt$ 43 | ^nn_dists.rcppannoy.cosine.cores_5.tbl 44 | ^nn_dists.rcppannoy.cosine.tbl 45 | ^nn_dists.rcppannoy.euclidean.cores_5.tbl 46 | ^nn_dists.rcppannoy.euclidean.tbl 47 | ^nn_idx.rcppannoy.cosine.cores_5.tbl 48 | ^nn_idx.rcppannoy.cosine.tbl 49 | ^nn_idx.rcppannoy.euclidean.cores_5.tbl 50 | ^nn_idx.rcppannoy.euclidean.tbl 51 | ^nn_short_nn_dists 52 | ^nn_short_nn_dists.bck 53 | ^nn_short_nn_idx 54 | ^nn_short_nn_idx.bck 55 | ^notes.bad_loop_ranges.20220211.txt$ 56 | ^packer_embryo.load.rds 57 | ^packer_embryo.processed_new_monocle3.rds 58 | ^packer_embryo.processed_old_monocle3.rds 59 | ^packer.load.hdf5 60 | ^packer_test_identity 61 | ^pdat.txt 62 | ^rna_transform_models_20210927 63 | ^row_names_full_cds.txt 64 | ^save_old.1$ 65 | ^supermodule_bin2d.pdf 66 | ^supermodule_bin2d.ps 67 | ^tests.3ab893f 68 | ^testthat_warning.txt 69 | ^tm 70 | ^transform_models.01 71 | ^transform_models.02 72 | ^transform_models.red_dim_aux.20211026 73 | ^w135.pancreas.s1_subject.pdf 74 | ^w136_pancreas_load.s1.rds 75 | ^w136.pancreas.s1_reference.pdf 76 | ^w136.pancreas.s1_subject.pdf 77 | ^w136.pancreas.s2_subject.pdf 78 | ^worm_embryo_coldata.rds 79 | ^worm_embryo_colnames.txt 80 | ^worm_embryo_expression_matrix.mtx 81 | ^worm_embryo_expression_matrix.rds 82 | ^worm_embryo_rowdata.rds 83 | ^worm_embryo_rownames.txt 84 | ^worm_embryo_variable_features.txt 85 | ^worm_l2_colnames.txt 86 | ^worm_l2_expression_matrix.mtx 87 | ^worm_l2_rownames.txt 88 | ^worm_l2_variable_features.txt 89 | ^R/NOTES 90 | ^R/nearest_neighbors.R.20211206a 91 | ^R/phoot 92 | ^R/save 93 | ^R/zzzz_old_files 94 | ^src/clustering.o 95 | ^src/monocle3.so 96 | ^src/RcppExports.o 97 | -------------------------------------------------------------------------------- /src/clustering.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace Rcpp; 3 | 4 | // Compute jaccard coefficient between nearest-neighbor sets 5 | // 6 | // Weights of both i->j and j->i are recorded if they have intersection. In this case 7 | // w(i->j) should be equal to w(j->i). In some case i->j has weights while j<-i has no 8 | // intersections, only w(i->j) is recorded. This is determinded in code `if(u>0)`. 9 | // The original method described in the phenograph paper is used to calculate the weight. 10 | // 11 | // Author: Chen Hao, Date: 25/09/2015; updated by Xiaojie Qiu Nov. 12, 2017 12 | 13 | NumericMatrix jaccard_coeff_cpp(NumericMatrix idx, bool weight) { 14 | int nrow = idx.nrow(), ncol = idx.ncol(), r = 0; 15 | NumericMatrix weights(nrow*ncol, 3); 16 | 17 | for(int i = 0; i < nrow; i ++) { 18 | for(int j = 0; j < ncol; j ++) { 19 | int k = idx(i,j) - 1; 20 | 21 | weights(r, 0) = i + 1; 22 | weights(r, 1) = k + 1; 23 | weights(r, 2) = 1; 24 | 25 | if(weight == TRUE) { 26 | 27 | NumericVector nodei = idx(i, _); 28 | NumericVector nodej = idx(k, _); 29 | 30 | int u = intersect(nodei, nodej).size(); // count intersection number 31 | int v = 2 * ncol - u; // count union number 32 | 33 | if(u>0) { 34 | // weights(r, 0) = i + 1; 35 | // weights(r, 1) = k + 1; 36 | // weights(r, 2) = u / (2.0 * ncol - u) / 2; // symmetrize the graph 37 | 38 | weights(r, 2) = (double) u / (double) v; // normalize the values 39 | } 40 | } 41 | 42 | r ++; 43 | 44 | } 45 | } 46 | 47 | weights(_, 2) = weights(_, 2) / max(weights(_, 2)); 48 | 49 | return weights; 50 | } 51 | 52 | // [[Rcpp::export]] 53 | NumericMatrix jaccard_coeff(SEXP R_idx, SEXP R_weight) { 54 | NumericMatrix idx(R_idx); 55 | bool weight = as(R_weight); 56 | 57 | return jaccard_coeff_cpp(idx, weight); 58 | } 59 | 60 | NumericMatrix pnorm_over_mat_cpp(NumericMatrix num_links_ij, NumericMatrix var_null_num_links) { 61 | int n = num_links_ij.nrow(); 62 | NumericMatrix tmp(n, n); 63 | 64 | for (int i = 0; i < n; i ++) { 65 | for (int j = 0; j < n; j ++) { 66 | // tmp(i, j) = Rcpp::pnorm( num_links_ij(i, j), 0.0, sqrt(var_null_num_links(i, j)), bool lower = false, bool log = false ); 67 | tmp(i, j) = R::pnorm(num_links_ij(i, j), 0.0, sqrt(var_null_num_links(i, j)), 0, 0); 68 | } 69 | } 70 | return tmp; 71 | } 72 | 73 | // [[Rcpp::export]] 74 | NumericMatrix pnorm_over_mat(SEXP R_num_links_ij, SEXP R_var_null_num_links) { 75 | NumericMatrix num_links_ij(R_num_links_ij); 76 | NumericMatrix var_null_num_links(R_var_null_num_links); 77 | 78 | return pnorm_over_mat_cpp(num_links_ij, var_null_num_links); 79 | } 80 | 81 | 82 | /*** 83 | edges$C = jaccard_dist 84 | edges = subset(edges, C != 0) 85 | edges$C = edges$C/max(edges$C) 86 | 87 | */ 88 | -------------------------------------------------------------------------------- /man/plot_percent_cells_positive.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_percent_cells_positive} 4 | \alias{plot_percent_cells_positive} 5 | \title{Plots the number of cells expressing one or more genes above a given value 6 | as a barplot} 7 | \usage{ 8 | plot_percent_cells_positive( 9 | cds_subset, 10 | group_cells_by = NULL, 11 | min_expr = 0, 12 | nrow = NULL, 13 | ncol = 1, 14 | panel_order = NULL, 15 | plot_as_count = FALSE, 16 | label_by_short_name = TRUE, 17 | normalize = TRUE, 18 | plot_limits = NULL, 19 | bootstrap_samples = 100, 20 | conf_int_alpha = 0.95 21 | ) 22 | } 23 | \arguments{ 24 | \item{cds_subset}{Subset cell_data_set to be plotted.} 25 | 26 | \item{group_cells_by}{the cell attribute (e.g. the column of colData(cds)) 27 | to group cells by on the horizontal axis. If NULL, all cells plotted as 28 | one group.} 29 | 30 | \item{min_expr}{the minimum (untransformed) expression level to consider the 31 | gene 'expressed'. Default is 0.} 32 | 33 | \item{nrow}{the number of panels per row in the figure.} 34 | 35 | \item{ncol}{the number of panels per column in the figure.} 36 | 37 | \item{panel_order}{the order in which genes should be laid out 38 | (left-to-right, top-to-bottom). Should be gene_short_name if 39 | \code{label_by_short_name = TRUE} or feature ID if 40 | \code{label_by_short_name = FALSE}.} 41 | 42 | \item{plot_as_count}{Logical, whether to plot as a count of cells rather 43 | than a percent. Default is FALSE.} 44 | 45 | \item{label_by_short_name}{label figure panels by gene_short_name (TRUE) or 46 | feature id (FALSE). Default is TRUE.} 47 | 48 | \item{normalize}{Logical, whether or not to normalize expression by size 49 | factor. Default is TRUE.} 50 | 51 | \item{plot_limits}{A pair of number specifying the limits of the y axis. If 52 | \code{NULL}, scale to the range of the data. Example \code{c(0,100)}.} 53 | 54 | \item{bootstrap_samples}{The number of bootstrap replicates to generate when 55 | plotting error bars. Default is 100.} 56 | 57 | \item{conf_int_alpha}{The size of the confidence interval to use when plotting 58 | error bars. Default is 0.95.} 59 | } 60 | \value{ 61 | a ggplot2 plot object 62 | } 63 | \description{ 64 | @description Accepts a subset cell_data_set and the parameter 65 | \code{group_cells_by}, used for dividing cells into groups. Returns one or 66 | more bar graphs (one graph for each gene in the cell_data_set). Each graph 67 | shows the percentage (or number) of cells that express a gene in each 68 | sub-group in the cell_data_set. 69 | } 70 | \examples{ 71 | \donttest{ 72 | cds <- load_a549() 73 | cds_subset <- cds[row.names(subset(rowData(cds), 74 | gene_short_name \%in\% c("NDRG4", "HBG2"))),] 75 | plot_percent_cells_positive(cds_subset, group_cells_by="culture_plate") 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /man/identity_table.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/identity.R 3 | \name{identity_table} 4 | \alias{identity_table} 5 | \title{Report matrix and model identity information.} 6 | \usage{ 7 | identity_table(cds) 8 | } 9 | \arguments{ 10 | \item{cds}{the cell_data_set to use.} 11 | } 12 | \value{ 13 | Write identity information to stdout. 14 | } 15 | \description{ 16 | Write the cell_data_set matrix and model 17 | identity information to stdout. 18 | } 19 | \details{ 20 | A matrix identity is a checksum that is stored 21 | in the cell_data_set when a reduced dimension matrix is 22 | created and when certain functions read count matrices 23 | into the cell_data_set, such as load_mm_data(). At the 24 | same time, the same checksum is stored as the model 25 | identity in order to link the model to its matrix. 26 | 27 | Additionally, Monocle3 stores the identity of the matrix 28 | from which the matrix was made. For example, in the case 29 | of a UMAP reduced dimension matrix made from a PCA 30 | reduced dimension matrix, the cell_data_set has the 31 | identities of both the UMAP and the PCA matrices. The 32 | UMAP identity is stored as 'matrix_id' and the PCA as 33 | 'prev_matrix_id'. Similarly, the model and the previous 34 | model identities are stored as 'model_id' and 35 | 'prev_model_id'. This allows one to trace a matrix 36 | to its origin, which may be helpful when a cell_data_set 37 | is partially reprocessed; for example, if preprocess_cds() 38 | is re-run but reduce_dimension() is not. Also, it may be 39 | helpful when transform models are loaded with the 40 | load_transform_models() function, in which case 41 | the matrix and model identities will differ. 42 | 43 | The identity of the model used to transform a matrix 44 | is stored with the matrix identity information as 45 | 'model_id'. Ordinarily, the matrix 'matrix_id' and 46 | 'model_id' and the corresponding model 'model_id' will 47 | have the same string value. However, they differ when 48 | the preprocess_transform() and reduce_dim_transform() 49 | functions are used to transform a matrix. 50 | 51 | Notes: 52 | \itemize{ 53 | \item Certain file and directory paths may be stored in the 54 | cell_data_set as identifiers. 55 | \item Checksums are calculated using the digest function in 56 | the digest package. The matrix dimensions are stored 57 | with the checksum. 58 | \item Matrix transformations such as subsetting and row and 59 | or column reordering do not affect the matrix identity. 60 | \item The matrix identity string is stored in the internal 61 | metadata slot of the cell_data_set and the model 62 | identity string is stored in the model object in the 63 | cds@reduce_dim_aux slot of the cell_data_set. 64 | } 65 | } 66 | \examples{ 67 | \donttest{ 68 | cds <- load_a549() 69 | cds <- preprocess_cds(cds) 70 | cds <- reduce_dimension(cds) 71 | identity_table(cds) 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /man/load_cellranger_data.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/load_cellranger_data.R 3 | \name{load_cellranger_data} 4 | \alias{load_cellranger_data} 5 | \title{Load data from the 10x Genomics Cell Ranger pipeline} 6 | \usage{ 7 | load_cellranger_data( 8 | pipestance_path = NULL, 9 | genome = NULL, 10 | barcode_filtered = TRUE, 11 | umi_cutoff = 100, 12 | matrix_control = list() 13 | ) 14 | } 15 | \arguments{ 16 | \item{pipestance_path}{Path to the output directory produced by Cell Ranger} 17 | 18 | \item{genome}{The desired genome (e.g., 'hg19' or 'mm10')} 19 | 20 | \item{barcode_filtered}{Load only the cell-containing barcodes} 21 | 22 | \item{umi_cutoff}{Numeric, desired cutoff to include a cell. Default is 100.} 23 | 24 | \item{matrix_control}{A list used to control how the counts matrix is stored 25 | in the CDS. By default, Monocle3 stores the counts matrix in memory as a 26 | sparse matrix. Setting 'matrix_control=list(matrix_class="BPCells")', 27 | stores the matrix on disk as a sparse matrix.} 28 | } 29 | \value{ 30 | a new cell_data_set object 31 | } 32 | \description{ 33 | Loads cellranger data into a cell_data_set object. Note that if your dataset 34 | is from version 3.0 and contains non-Gene-Expression data (e.g. Antibodies 35 | or CRISPR features), only the Gene Expression data is returned. 36 | } 37 | \details{ 38 | \itemize{ 39 | \item the pipestance_path argument takes the name of a Cell Ranger 40 | output directory, in which it looks for the required data files, 41 | for example, pipestance_path=10x_data 42 | \item for Cell Ranger version 2 data, load_cellranger_data expects to 43 | find the required files barcodes.tsv, genes.tsv, and 44 | matrix.mtx in the directories as 45 | \itemize{ 46 | \item 10x_data/outs/filtered_gene_bc_matrices/\if{html}{\out{}}/barcodes.tsv 47 | \item 10x_data/outs/filtered_gene_bc_matrices/\if{html}{\out{}}/genes.tsv 48 | \item 10x_data/outs/filtered_gene_bc_matrices/\if{html}{\out{}}/matrix.mtx 49 | } 50 | 51 | where \if{html}{\out{}} is the name of a genome. load_cellranger_data 52 | expects to find either a single genome directory in 53 | 10x_data/outs/filtered_gene_bc_matrices or a genome 54 | directory with the name given with the genome argument. 55 | \item for Cell Ranger version 3 data, load_cellranger_data expects to 56 | find the required files barcodes.tsv.gz, features.tsv.gz, 57 | and matrix.mtx.gz in the directories as 58 | \itemize{ 59 | \item 10x_data/outs/filtered_feature_bc_matrix/barcodes.tsv.gz 60 | \item 10x_data/outs/filtered_feature_bc_matrix/features.tsv.gz 61 | \item 10x_data/outs/filtered_feature_bc_matrix/matrix.mtx.gz 62 | } 63 | \item if any of the files is not in the expected directory, 64 | load_cellranger_data will terminate with an error 65 | } 66 | } 67 | \examples{ 68 | \donttest{ 69 | cell_ranger_data <- system.file("extdata", "cell_ranger_3", package = "monocle3") 70 | gene_bc_matrix <- load_cellranger_data(cell_ranger_data) 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /inst/extdata/worm_l2/NOTES: -------------------------------------------------------------------------------- 1 | == load worm L2 data and select neuronal cells 2 | 3 | expression_matrix <- readRDS(url("http://staff.washington.edu/hpliner/data/cao_l2_expression.rds")) 4 | cell_metadata <- readRDS(url("http://staff.washington.edu/hpliner/data/cao_l2_colData.rds")) 5 | gene_annotation <- readRDS(url("http://staff.washington.edu/hpliner/data/cao_l2_rowData.rds")) 6 | 7 | cds <- new_cell_data_set(expression_matrix, 8 | cell_metadata = cell_metadata, 9 | gene_metadata = gene_annotation) 10 | 11 | cds <- cds[,colData(cds)$cao_cell_type %in% c("Unclassified neurons", "Touch receptor neurons", "Pharyngeal neurons", "flp-1(+) interneurons", "Canal associated neurons", "Ciliated sensory neurons", "Other interneurons", "Oxygen sensory neurons")] 12 | 13 | library(Matrix) 14 | writeMM(counts(cds),file='worm_l2_expression_matrix.mtx') 15 | write.table(rownames(cds), file='worm_l2_rownames.txt',row.names=FALSE,col.names=FALSE) 16 | write.table(colnames(cds), file='worm_l2_colnames.txt',row.names=FALSE,col.names=FALSE) 17 | 18 | 19 | == Seurat variable feature selection 20 | 21 | dat <- ReadMtx('worm_l2_expression_matrix.mtx', cells='worm_l2_colnames.txt', features='worm_l2_rownames.txt', cell.column=1, feature.column=1) 22 | 23 | wl2 <- CreateSeuratObject(counts = dat, project = "worm_l2", min.cells = 3, min.features = 100) 24 | 25 | wl2 <- NormalizeData(wl2) 26 | wl2 <- FindVariableFeatures(wl2, selection.method = "vst", nfeatures = 10000) 27 | 28 | var_fea <- VariableFeatures(wl2) 29 | 30 | write.table(var_fea, file='/home/brent/git/monocle3/worm_l2_variable_features.txt', row.names=FALSE, col.names=FALSE) 31 | 32 | 33 | == subset cds on most variable features 34 | 35 | var_fea <- read.table('worm_l2_variable_features.txt') 36 | cds <- cds[rownames(cds) %in% var_fea[[1]][1:5000],] 37 | 38 | saveRDS(counts(cds), file='worm_l2_expression_matrix.rds') 39 | saveRDS(colData(cds), file='worm_l2_coldata.rds') 40 | saveRDS(rowData(cds), file='worm_l2_rowdata.rds') 41 | 42 | 43 | == load sub-setted worm L2 data 44 | 45 | expression_matrix <- readRDS(system.file('extdata', 'worm_l2/worm_l2_expression_matrix.rds', package='monocle3')) 46 | cell_metadata <- readRDS(system.file('extdata', 'worm_l2/worm_l2_coldata.rds', package='monocle3')) 47 | gene_metadata <- readRDS(system.file('extdata', 'worm_l2/worm_l2_rowdata.rds', package='monocle3')) 48 | 49 | cds <- new_cell_data_set(expression_data=expression_matrix, 50 | cell_metadata=cell_metadata, 51 | gene_metadata=gene_metadata) 52 | 53 | 54 | #' expression_matrix <- readRDS(system.file('extdata', 'worm_l2/worm_l2_expression_matrix.rds', package='monocle3')) 55 | #' cell_metadata <- readRDS(system.file('extdata', 'worm_l2/worm_l2_coldata.rds', package='monocle3')) 56 | #' gene_metadata <- readRDS(system.file('extdata', 'worm_l2/worm_l2_rowdata.rds', package='monocle3')) 57 | #' 58 | #' cds <- new_cell_data_set(expression_data=expression_matrix, 59 | #' cell_metadata=cell_metadata, 60 | #' gene_metadata=gene_metadata) 61 | #' 62 | -------------------------------------------------------------------------------- /man/plot_genes_by_group.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotting.R 3 | \name{plot_genes_by_group} 4 | \alias{plot_genes_by_group} 5 | \title{Create a dot plot to visualize the mean gene expression and percentage of 6 | expressed cells in each group of cells} 7 | \usage{ 8 | plot_genes_by_group( 9 | cds, 10 | markers, 11 | group_cells_by = "cluster", 12 | reduction_method = "UMAP", 13 | norm_method = c("log", "size_only"), 14 | lower_threshold = 0, 15 | max.size = 10, 16 | ordering_type = c("cluster_row_col", "maximal_on_diag", "none"), 17 | axis_order = c("group_marker", "marker_group"), 18 | flip_percentage_mean = FALSE, 19 | pseudocount = 1, 20 | scale_max = 3, 21 | scale_min = -3, 22 | color_by_group = FALSE 23 | ) 24 | } 25 | \arguments{ 26 | \item{cds}{A cell_data_set for plotting.} 27 | 28 | \item{markers}{A list of gene ids (or short names) to show in the plot} 29 | 30 | \item{group_cells_by}{How to group cells when labeling them. Must be either 31 | the name of a column of colData(cds), or one of "clusters" or "partitions". 32 | If a column in colData(cds), must be a categorical variable.} 33 | 34 | \item{reduction_method}{The dimensionality reduction method used for clusters 35 | and partitions.} 36 | 37 | \item{norm_method}{Determines how to transform expression values prior to 38 | plotting. Options are "log" and "size_only". Default is "log".} 39 | 40 | \item{lower_threshold}{The lowest gene expressed treated as expressed. By 41 | default, zero.} 42 | 43 | \item{max.size}{The maximum size of the dot. By default, it is 10.} 44 | 45 | \item{ordering_type}{How to order the genes / groups on the dot plot. Only 46 | accepts 'cluster_row_col' (use biclustering to cluster the rows and 47 | columns), 'maximal_on_diag' (position each column so that the maximal color 48 | shown on each column on the diagonal, if the current maximal is used in 49 | earlier columns, the next largest one is position), and 'none' (preserve 50 | the ordering from the input gene or alphabetical ordering of groups). 51 | Default is 'cluster_row_col'.} 52 | 53 | \item{axis_order}{Whether to put groups on x-axis, genes on y-axis (option 54 | 'group_marker') or the reverse order (option 'marker_group'). Default is 55 | "group_marker".} 56 | 57 | \item{flip_percentage_mean}{Logical indicating whether to use color of the 58 | dot to represent the percentage (by setting flip_percentage_mean = FALSE, 59 | default) and size of the dot the mean expression, or the opposite (by 60 | setting flip_percentage_mean = TRUE).} 61 | 62 | \item{pseudocount}{A pseudo-count added to the average gene expression.} 63 | 64 | \item{scale_max}{The maximum value (in standard deviations) to show in the 65 | heatmap. Values larger than this are set to the max.} 66 | 67 | \item{scale_min}{The minimum value (in standard deviations) to show in the 68 | heatmap. Values smaller than this are set to the min.} 69 | 70 | \item{color_by_group}{Color cells by the group to which they belong.} 71 | } 72 | \value{ 73 | a ggplot2 plot object 74 | } 75 | \description{ 76 | Create a dot plot to visualize the mean gene expression and percentage of 77 | expressed cells in each group of cells 78 | } 79 | -------------------------------------------------------------------------------- /vignettes/monocle3-vignette.Rnw: -------------------------------------------------------------------------------- 1 | % \VignetteIndexEntry{Monocle3: Cell counting, differential expression, and trajectory analysis for single-cell RNA-Seq experiments} 2 | % \VignetteEngine{knitr::knitr} 3 | % \VignetteDepends{} 4 | % \VignettePackage{monocle3} 5 | 6 | \documentclass[10pt,oneside]{article} 7 | 8 | \newcommand{\thetitle}{Monocle3: Cell counting, differential expression, and trajectory analysis for single-cell RNA-Seq experiments} 9 | 10 | %\usepackage[pdftitle={\thetitle},pdfauthor={Wolfgang Huber}]{whbiocvignette} 11 | \usepackage{whbiocvignette} 12 | % \usepackage{times} 13 | %\usepackage{hyperref} 14 | %\usepackage{verbatim} 15 | %\usepackage{graphicx} 16 | %\usepackage{fancybox} 17 | %\usepackage{color} 18 | 19 | \title{\textsf{\textbf{\thetitle}}} 20 | \author{Cole Trapnell\\[1em]University of Washington,\\ Seattle, Washington, USA\\ 21 | \texttt{coletrap@uw.edu} \and 22 | Davide Cacchiarelli\\[1em]Harvard University,\\ Cambridge, Massachussetts, USA\\ 23 | \texttt{davide@broadinstitute.org}\and 24 | Xiaojie Qiu\\[1em]University of Washington,\\ Seattle, Washington, USA\\ 25 | \texttt{xqiu@uw.edu} 26 | } 27 | \begin{document} 28 | 29 | <>= 30 | library(knitr) 31 | opts_chunk$set( 32 | #concordance=TRUE 33 | ) 34 | @ 35 | 36 | 37 | 38 | 39 | <>= 40 | library(Biobase) 41 | library(knitr) 42 | library(reshape2) 43 | library(ggplot2) 44 | 45 | knitr::opts_chunk$set(autodep=TRUE, cache=FALSE, warning=FALSE, dev='png', dpi=600) 46 | set.seed(0) 47 | @ %def 48 | 49 | \maketitle 50 | 51 | \begin{abstract} 52 | Single cell gene expression studies enable profiling of transcriptional regulation during complex biological processes and within highly hetergeneous cell populations. These studies allow discovery of genes that identify certain subtypes of cells, or that mark a particular intermediate states during a biological process. In many single cell studies, individual cells are executing through a gene expression program in an unsynchronized manner. In effect, each cell is a snapshot of the transcriptional program under study. The package \Rpackage{monocle3} provides tools for analyzing single-cell expression experiments. Monocle3 introduced the strategy of ordering single cells in \emph{pseudotime}, placing them along a trajectory corresponding to a biological process such as cell differentiation. Monocle3 learns this trajectory directly from the data, in either a fully unsupervised or a semi-supervised manner. It also performs differential gene expression and clustering to identify important genes and cell states. It is designed for RNA-Seq studies, but can be used with other assays. For more information on the algorithm at the core of \Rpackage{monocle3}, or to learn more about how to use single cell RNA-Seq to study a complex biological process, see the original work by Trapnell and Cacchiarelli \emph{et al} and more recent updates by Qiu et al. 53 | \end{abstract} 54 | 55 | For information on Monocle3's features and how to utilize them, go to https://cole-trapnell-lab.github.io/monocle3/ and go to the "Documentation" tab displayed at the top of the page. 56 | 57 | <>= 58 | plot(1:10) 59 | @ %def 60 | \end{document} 61 | -------------------------------------------------------------------------------- /man/order_cells.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/order_cells.R 3 | \name{order_cells} 4 | \alias{order_cells} 5 | \title{Orders cells according to pseudotime.} 6 | \usage{ 7 | order_cells( 8 | cds, 9 | reduction_method = "UMAP", 10 | root_pr_nodes = NULL, 11 | root_cells = NULL, 12 | verbose = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{cds}{the cell_data_set upon which to perform this operation} 17 | 18 | \item{reduction_method}{a string specifying the reduced dimension method to 19 | use when ordering cells. Currently only "UMAP" is supported.} 20 | 21 | \item{root_pr_nodes}{NULL or a vector of starting principal points. If 22 | provided, pseudotime will start (i.e. be zero) at these graph nodes. You 23 | can find the principal point names by running plot_cells with 24 | label_principal_points = TRUE. Both \code{root_pr_nodes} and 25 | \code{root_cells} cannot be provided.} 26 | 27 | \item{root_cells}{NULL or a vector of starting cells. If provided, 28 | pseudotime will start (i.e. be zero) at these cells. Both 29 | \code{root_pr_nodes} and \code{root_cells} cannot be provided.} 30 | 31 | \item{verbose}{Whether to show running information for order_cells} 32 | } 33 | \value{ 34 | an updated cell_data_set object. 35 | } 36 | \description{ 37 | Assigns cells a pseudotime value based on their projection on the principal 38 | graph learned in the \code{learn_graph} function and the position of chosen 39 | root states. This function takes as input a cell_data_set and returns it 40 | with pseudotime information stored internally. 41 | \code{order_cells()} optionally takes "root" state(s) in the form of cell 42 | or principal graph node IDs, which you can use to specify the start of the 43 | trajectory. If you don't provide a root state, an plot will be generated 44 | where you can choose the root state(s) interactively. The trajectory will be 45 | composed of segments. 46 | } 47 | \examples{ 48 | \donttest{ 49 | cell_metadata <- readRDS(system.file('extdata', 50 | 'worm_embryo/worm_embryo_coldata.rds', 51 | package='monocle3')) 52 | gene_metadata <- readRDS(system.file('extdata', 53 | 'worm_embryo/worm_embryo_rowdata.rds', 54 | package='monocle3')) 55 | expression_matrix <- readRDS(system.file('extdata', 56 | 'worm_embryo/worm_embryo_expression_matrix.rds', 57 | package='monocle3')) 58 | 59 | cds <- new_cell_data_set(expression_data=expression_matrix, 60 | cell_metadata=cell_metadata, 61 | gene_metadata=gene_metadata) 62 | 63 | cds <- preprocess_cds(cds) 64 | cds <- align_cds(cds, alignment_group = 65 | "batch", residual_model_formula_str = "~ bg.300.loading + 66 | bg.400.loading + bg.500.1.loading + bg.500.2.loading + 67 | bg.r17.loading + bg.b01.loading + bg.b02.loading") 68 | cds <- reduce_dimension(cds) 69 | cds <- cluster_cells(cds) 70 | cds <- learn_graph(cds) 71 | cds <- order_cells(cds, root_pr_nodes='Y_21') 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /00travis.yml: -------------------------------------------------------------------------------- 1 | # Notes: 2 | # o add Rscript -e 'devtools::install_version("locfit", version="1.5-9.4")' because the new 1.5-9.5 version 3 | # requires >= R 4.1.0 4 | # o add Rscript -e 'devtools::install_github('r-spatial/sf') because the current sf version (1.0-6) does 5 | # not build. 6 | # o add lines to before_install in order to install recent cmake version, which is required by the recent 7 | # nloptr version. These lines are 8 | # - sudo wget -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo apt-key add - 9 | # - sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial main' 10 | # - sudo apt-get update 11 | # - sudo apt-get install -y cmake 12 | 13 | --- 14 | cache: packages 15 | sudo: required 16 | warnings_are_errors: true 17 | os: linux 18 | dist: focal 19 | language: r 20 | before_install: 21 | - sudo apt-get install -y libnlopt-dev 22 | - sudo apt-get install -y libudunits2-dev 23 | - sudo apt-get install -y gdal-bin 24 | - sudo apt-get install -y libgdal-dev 25 | - sudo apt-get install -y libharfbuzz-dev 26 | - sudo apt-get install -y libfribidi-dev 27 | - sudo apt-get install -y libgit2-dev 28 | - sudo wget -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo apt-key add - 29 | - sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ jammy main' 30 | - sudo apt-get update 31 | - sudo apt-get install -y cmake 32 | r: 33 | - bioc-release 34 | before_script: 35 | - Rscript -e 'install.packages("leidenbase")' 36 | - Rscript -e 'install.packages("devtools")' 37 | - Rscript -e 'devtools::install_version("locfit", version="1.5-9.4")' 38 | - Rscript -e 'devtools::install_github("r-spatial/sf")' 39 | - export PKG_NAME=$(Rscript -e 'cat(paste0(devtools::as.package(".")$package))') 40 | - export PKG_TARBALL=$(Rscript -e 'pkg <- devtools::as.package("."); cat(paste0(pkg$package,"_",pkg$version,".tar.gz"))') 41 | - R CMD build --no-build-vignettes . 42 | - R CMD INSTALL ${PKG_TARBALL} 43 | - rm ${PKG_TARBALL} 44 | - echo "Session info:" 45 | - Rscript -e "library(${PKG_NAME});devtools::session_info('${PKG_NAME}')" 46 | - Rscript -e "library(${PKG_NAME});devtools::session_info()" 47 | 48 | script: 49 | - | 50 | export _R_CHECK_DONTTEST_EXAMPLES_=false 51 | R CMD build . 52 | export PKG_TARBALL=$(Rscript -e 'pkg <- devtools::as.package("."); cat(paste0(pkg$package,"_",pkg$version,".tar.gz"))') 53 | export TESTTHAT_MAX_FAILS=Inf 54 | if [ ! -f "$PKG_TARBALL" ]; then exit 1; fi 55 | travis_wait 20 R CMD check monocle3*tar.gz 56 | 57 | after_failure: 58 | - Rscript -e 'devtools::install();devtools::test()' 59 | 60 | notifications: 61 | slack: 62 | secure: FH+TwlrNXm1q2RGtIfVJn0pUfzlR9WXRE6mPYLy2y3mRjX+Uo4g6nG2X2cNUXQLapVjb6UWb5plJfDaajUr1AMdnRo9PcgxcRiYDLEaR/yiRPNp7p6rnC7mEbMDywincdGy9g/OhiTLqgwWwE925b9Mpim7zTGDE0Du4dz3VNUm6aQi1xY/S2LT8xnL1Y4/LyYwGzWSy6kyxRgxNKlIDVs28m7cER9xWzTFG0LG3VcWupPujRWYFV3JDuqMp6m4jWQ7gq4v0PIgyj+unZaa2eyE288E9xp5knhgZzvooN0P0IODnLF4GIBh48iyMuapllx1oaDEHRtjOWCljPugNLK1KQrSrnB95o/2BL3d0WtNv40nteaPP7Fed1+NfF2Zu11nSIfbc1fA1gXdk/AriYHalMmdsp45q3EVx3tkJ4bwcU0ox00HbVUJfeAhb/NwOkZzw1+jHSwB61SxRpyaTi81O3vKcBIxRKD+R1GFOYgGOafqqbf/GHsBFJH718iUyih2WV1Y+HktqbZ+yrViyuO/4Gmf352eq4gsvKJ5Kdap9xAjFyQMXrVFJ7Nm4q81z+r3/xs59fWuQyY+LXYyHYy0xygeinM/fAd2oTweeIR4y4DTBR5t673PPh3PC64xGDE3u29LUAcva5xOqUtdvuPM+2wLAHs8qqpqg+yS9aEo= 63 | 64 | -------------------------------------------------------------------------------- /man/save_transform_models.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/io.R 3 | \name{save_transform_models} 4 | \alias{save_transform_models} 5 | \title{Save cell_data_set transform models.} 6 | \usage{ 7 | save_transform_models( 8 | cds, 9 | directory_path, 10 | comment = "", 11 | verbose = TRUE, 12 | archive_control = list() 13 | ) 14 | } 15 | \arguments{ 16 | \item{cds}{a cell_data_set with existing models.} 17 | 18 | \item{directory_path}{a string giving the name of the directory 19 | in which to write the model files.} 20 | 21 | \item{comment}{a string with optional notes that is saved with 22 | the objects.} 23 | 24 | \item{verbose}{a boolean determining whether to print information 25 | about the saved files.} 26 | 27 | \item{archive_control}{a list that is used to control archiving 28 | the output directory. The archive_control parameters are 29 | \describe{ 30 | \item{archive_type}{a string giving the method used to 31 | archive the directory. The acceptable values are 32 | "tar" and "none". The directory is not archived when 33 | archive_type is "none". The default is "tar".} 34 | \item{archive_compression}{a string giving the type of 35 | compression applied to the archive file. The acceptable 36 | values are "none", "gzip", "bzip2", and "xz". The 37 | default is "none".} 38 | }} 39 | } 40 | \value{ 41 | none. 42 | } 43 | \description{ 44 | Save the transform models in the cell_data_set to the 45 | specified directory by writing the R objects to RDS 46 | files and the nearest neighbor indices to 47 | index files. save_transform_models saves transform 48 | models made by running the preprocess_cds and 49 | reduce_dimension functions on an initial cell_data_set. 50 | Subsequent cell_data_sets are transformed into the 51 | reduced dimension space of the initial cell_data_set by 52 | loading the new data into a new cell_data_set, loading 53 | the initial data set transform models into the new 54 | cell_data_set using the load_transform_models function, 55 | and applying those transform models to the new data set 56 | using the preprocess_transform() and 57 | reduce_dimension_transform() functions. In this case, do 58 | not run the preprocess_cds() or reduce_dimension() 59 | functions on the new cell_data_set. Additionally, 60 | save_transform_models() saves nearest neighbor indices 61 | when the preprocess_cds() and reduce_dimension() 62 | functions are run with the make_nn_index=TRUE parameter. 63 | These indices are used to find matches between cells in 64 | the new processed cell_data_set and the initial 65 | cell_data_set using index search functions. For more 66 | information see the help for transfer_cell_labels(). 67 | save_transform_models() saves the models to a directory 68 | given by the directory_path parameter. 69 | } 70 | \section{Notes}{ 71 | 72 | \itemize{ 73 | \item{The R tar archive function used by Monocle3 may have 74 | a limited output file size of 8 GB. If you encounter 75 | this problem, you can set the environment variable 76 | "tar" to a tar executable that has no size limit, 77 | for example, gnu tar. You can do this in the 78 | $HOME/.monoclerc file by adding a line consisting of 79 | Sys.setenv('tar' = paste(Sys.getenv("TAR"), "-H", "gnu")). 80 | See the R 'tar' documentation for more information.} 81 | } 82 | } 83 | 84 | \examples{ 85 | \dontrun{ 86 | cds <- load_a549() 87 | cds <- preprocess_cds(cds) 88 | cds <- reduce_dimension(cds) 89 | save_transform_models(cds, 'tm') 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /man/preprocess_transform.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/projection.R 3 | \name{preprocess_transform} 4 | \alias{preprocess_transform} 5 | \title{Apply a preprocess transform model to a cell_data_set.} 6 | \usage{ 7 | preprocess_transform( 8 | cds, 9 | reduction_method = c("PCA", "LSI"), 10 | block_size = NULL, 11 | cores = 1, 12 | verbose = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{cds}{a cell_data_set to be transformed.} 17 | 18 | \item{reduction_method}{a previously loaded transform 19 | model that is used to reduce the dimensions of the 20 | count matrix in the cell_data_set. The "PCA" and "LSI" 21 | transforms are supported. The default is "PCA".} 22 | 23 | \item{block_size}{a numeric value for the DelayedArray 24 | block size used only in this function. Default is 25 | NULL, which does not affect the current block size.} 26 | 27 | \item{cores}{the number of cores to use for the matrix 28 | multiplication. The default is 1.} 29 | 30 | \item{verbose}{logical Whether to emit verbose output during dimensionality 31 | reduction.} 32 | } 33 | \value{ 34 | a cell_data_set with a preprocess reduced count 35 | matrix. 36 | } 37 | \description{ 38 | Applies a previously calculated preprocess 39 | transform model to a new count matrix. For more 40 | information read the help information for save_transform_models. 41 | } 42 | \section{Preprocessing notes}{ 43 | 44 | \describe{ 45 | \item{Filtering:}{apply the same filters to the query and 46 | reference data set. For example, use the 47 | same UMI cutoff value for both data sets. 48 | You can check the cutoff value by finding 49 | the range of UMI values before applying 50 | normalization using range(counts(cds)).} 51 | \item{Size factors:}{use the same method and round_exprs 52 | parameters to calculate the Size_Factor 53 | values for both data sets. See the 54 | estimate_size_factors() help for 55 | additional information.} 56 | \item{Troubleshooting:}{if the projection fails, try 57 | comparing histograms of various 58 | values of the reference and query 59 | data sets. For example, in order to 60 | examine the size factor values use 61 | hist(colData(cds)[['Size_Factor']], breaks=100).} 62 | } 63 | } 64 | 65 | \examples{ 66 | \dontrun{ 67 | cell_metadata <- readRDS(system.file('extdata', 68 | 'worm_embryo/worm_embryo_coldata.rds', 69 | package='monocle3')) 70 | gene_metadata <- readRDS(system.file('extdata', 71 | 'worm_embryo/worm_embryo_rowdata.rds', 72 | package='monocle3')) 73 | expression_matrix <- readRDS(system.file('extdata', 74 | 'worm_embryo/worm_embryo_expression_matrix.rds', 75 | package='monocle3')) 76 | 77 | cds <- new_cell_data_set(expression_data=expression_matrix, 78 | cell_metadata=cell_metadata, 79 | gene_metadata=gene_metadata) 80 | 81 | ncell <- nrow(colData(cds)) 82 | cell_sample <- sample(seq(ncell), 2 * ncell / 3) 83 | cell_set <- seq(ncell) \%in\% cell_sample 84 | cds1 <- cds[,cell_set] 85 | cds1 <- preprocess_cds(cds1) 86 | save_transform_models(cds1, 'tm') 87 | cds2 <- cds[,!cell_set] 88 | cds2 <- load_transform_models(cds2, 'tm') 89 | cds2 <- preprocess_transform(cds2, 'PCA') 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /inst/extdata/worm_embryo/NOTES: -------------------------------------------------------------------------------- 1 | == load worm embryo data and select cell subset 2 | 3 | expression_matrix <- readRDS(url("http://staff.washington.edu/hpliner/data/packer_embryo_expression.rds")) 4 | cell_metadata <- readRDS(url("http://staff.washington.edu/hpliner/data/packer_embryo_colData.rds")) 5 | gene_annotation <- readRDS(url("http://staff.washington.edu/hpliner/data/packer_embryo_rowData.rds")) 6 | 7 | cds <- new_cell_data_set(expression_matrix, 8 | cell_metadata = cell_metadata, 9 | gene_metadata = gene_annotation) 10 | 11 | cds <- cds[,colData(cds)[['cell.type']] %in% c('Neuroblast_ASG_AWA', 'ASG_AWA', 'ADL', 'AWC_ON', 'AWC', 'AWA', 'AWB', 'ASG', 'ADL_parent')] 12 | 13 | library(Matrix) 14 | writeMM(counts(cds), file='worm_embryo_expression_matrix.mtx') 15 | write.table(colnames(cds), file='worm_embryo_colnames.txt', row.names=FALSE, col.names=FALSE) 16 | write.table(rownames(cds), file='worm_embryo_rownames.txt', row.names=FALSE, col.names=FALSE) 17 | 18 | 19 | == Seurat variable feature selection 20 | 21 | dat <- ReadMtx('worm_embryo_expression_matrix.mtx', cells='worm_embryo_colnames.txt', features='worm_embryo_rownames.txt', cell.column=1, feature.column=1) 22 | 23 | worm_embryo <- CreateSeuratObject(counts = dat, project = "worm_embryo", min.cells = 3, min.features = 100) 24 | 25 | worm_embryo <- NormalizeData(worm_embryo) 26 | worm_embryo <- FindVariableFeatures(worm_embryo, selection.method = "vst", nfeatures = 10000) 27 | 28 | var_fea <- VariableFeatures(worm_embryo) 29 | 30 | write.table(var_fea, file='/home/brent/git/monocle3/worm_embryo_variable_features.txt', row.names=FALSE, col.names=FALSE) 31 | 32 | 33 | == subset cds on most variable features 34 | 35 | 36 | var_fea <- read.table('worm_embryo_variable_features.txt') 37 | cds<-cds[rownames(cds) %in% var_fea[[1]][1:10000],] 38 | 39 | saveRDS(rowData(cds), file='worm_embryo_rowdata.rds') 40 | saveRDS(colData(cds), file='worm_embryo_coldata.rds') 41 | saveRDS(counts(cds), file='worm_embryo_expression_matrix.rds') 42 | 43 | 44 | == load sub-setted worm embryo data 45 | 46 | cell_metadata <- readRDS(system.file('extdata', 'worm_embryo/worm_embryo_coldata.rds', package='monocle3')) 47 | gene_metadata <- readRDS(system.file('extdata', 'worm_embryo/worm_embryo_rowdata.rds', package='monocle3')) 48 | expression_matrix <- readRDS(system.file('extdata', 'worm_embryo/worm_embryo_expression_matrix.rds', package='monocle3')) 49 | 50 | cds <- new_cell_data_set(expression_data=expression_matrix, 51 | cell_metadata=cell_metadata, 52 | gene_metadata=gene_metadata) 53 | 54 | 55 | == process worm embryo cds to order cells 56 | 57 | cell_metadata <- readRDS(system.file('extdata', 'worm_embryo/worm_embryo_coldata.rds', package='monocle3')) 58 | gene_metadata <- readRDS(system.file('extdata', 'worm_embryo/worm_embryo_rowdata.rds', package='monocle3')) 59 | expression_matrix <- readRDS(system.file('extdata', 'worm_embryo/worm_embryo_expression_matrix.rds', package='monocle3')) 60 | 61 | cds <- new_cell_data_set(expression_data=expression_matrix, 62 | cell_metadata=cell_metadata, 63 | gene_metadata=gene_metadata) 64 | 65 | cds <- preprocess_cds(cds,num_dim=50) 66 | cds <- align_cds(cds, alignment_group = "batch", residual_model_formula_str = "~ bg.300.loading + bg.400.loading + bg.500.1.loading + bg.500.2.loading + bg.r17.loading + bg.b01.loading + bg.b02.loading") 67 | cds <- reduce_dimension(cds) 68 | cds <- cluster_cells(cds) 69 | cds <- learn_graph(cds) 70 | cds <- order_cells(cds,root_pr_nodes='Y_27') 71 | 72 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to make participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies within all project spaces, and it also applies when 49 | an individual is representing the project or its community in public spaces. 50 | Examples of representing a project or community include using an official 51 | project e-mail address, posting via an official social media account, or acting 52 | as an appointed representative at an online or offline event. Representation of 53 | a project may be further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at coletrap [at] uw.edu. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | 78 | -------------------------------------------------------------------------------- /man/fit_models.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/expr_models.R 3 | \name{fit_models} 4 | \alias{fit_models} 5 | \title{Fits a model for each gene in a cell_data_set object.} 6 | \usage{ 7 | fit_models( 8 | cds, 9 | model_formula_str, 10 | expression_family = "quasipoisson", 11 | reduction_method = "UMAP", 12 | cores = 1, 13 | clean_model = TRUE, 14 | verbose = FALSE, 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{cds}{The cell_data_set upon which to perform this operation.} 20 | 21 | \item{model_formula_str}{A formula string specifying the model to fit for 22 | the genes.} 23 | 24 | \item{expression_family}{Specifies the family function used for expression 25 | responses. Can be one of "quasipoisson", "negbinomial", "poisson", 26 | "binomial", "gaussian", "zipoisson", "zinegbinomial", or "mixed-negbinomial". 27 | Default is "quasipoisson".} 28 | 29 | \item{reduction_method}{Which method to use with clusters() and 30 | partitions(). Default is "UMAP".} 31 | 32 | \item{cores}{The number of processor cores to use during fitting.} 33 | 34 | \item{clean_model}{Logical indicating whether to clean the model. Default is 35 | TRUE.} 36 | 37 | \item{verbose}{Logical indicating whether to emit progress messages.} 38 | 39 | \item{...}{Additional arguments passed to model fitting functions.} 40 | } 41 | \value{ 42 | a tibble where the rows are genes and columns are 43 | \itemize{ 44 | \item id character vector from \code{rowData(cds)$id} 45 | \item gene_short_names character vector from \code{rowData(cds)$gene_short_names} 46 | \item num_cells_expressed int vector from \code{rowData(cds)$num_cells_expressed} 47 | \item gene_id character vector from row.names(rowData(cds))` 48 | \item model GLM model list returned by speedglm 49 | \item model_summary model summary list returned by \code{summary(model)} 50 | \item status character vector of model fitting status: OK when model converged, otherwise FAIL 51 | } 52 | } 53 | \description{ 54 | This function fits a generalized linear model for each gene in a 55 | cell_data_set. Formulae can be provided to account for additional covariates 56 | (e.g. day collected, genotype of cells, media conditions, etc). 57 | } 58 | \examples{ 59 | \donttest{ 60 | cell_metadata <- readRDS(system.file('extdata', 61 | 'worm_embryo/worm_embryo_coldata.rds', 62 | package='monocle3')) 63 | gene_metadata <- readRDS(system.file('extdata', 64 | 'worm_embryo/worm_embryo_rowdata.rds', 65 | package='monocle3')) 66 | expression_matrix <- readRDS(system.file('extdata', 67 | 'worm_embryo/worm_embryo_expression_matrix.rds', 68 | package='monocle3')) 69 | 70 | cds <- new_cell_data_set(expression_data=expression_matrix, 71 | cell_metadata=cell_metadata, 72 | gene_metadata=gene_metadata) 73 | 74 | cds <- preprocess_cds(cds, num_dim=50) 75 | cds <- align_cds(cds, alignment_group = "batch", 76 | residual_model_formula_str = "~ bg.300.loading + bg.400.loading + 77 | bg.500.1.loading + bg.500.2.loading + bg.r17.loading + bg.b01.loading + 78 | bg.b02.loading") 79 | cds <- reduce_dimension(cds) 80 | ciliated_genes <- c("che-1", "hlh-17", "nhr-6", "dmd-6", "ceh-36", "ham-1") 81 | cds_subset <- cds[rowData(cds)$gene_short_name \%in\% ciliated_genes,] 82 | gene_fits <- fit_models(cds_subset, model_formula_str = "~embryo.time") 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /man/set_matrix_control.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/matrix.R 3 | \name{set_matrix_control} 4 | \alias{set_matrix_control} 5 | \title{Verify and set the matrix_control parameter list.} 6 | \usage{ 7 | set_matrix_control( 8 | matrix_control = list(), 9 | matrix_control_default = list(), 10 | control_type = c("unrestricted", "pca") 11 | ) 12 | } 13 | \arguments{ 14 | \item{matrix_control}{Input control list.} 15 | 16 | \item{matrix_control_default}{Input default control list.} 17 | 18 | \item{control_type}{A string of either "unrestricted" or "pca". A control_type of "pca" 19 | restricts certain list parameters.} 20 | } 21 | \value{ 22 | matrix_control Output control list. 23 | } 24 | \description{ 25 | Verifies and sets the list of parameter values 26 | that is used to make the count matrix that is stored in the 27 | cell_data_set or certain other matrices that are used 28 | during the Monocle3 run. To see the 29 | default values, 30 | call "set_matrix_control(matrix_control=list(matrix_class='BPCells', show_values=TRUE))". 31 | "show_values=TRUE" can be used in functions that have the 32 | matrix_control list parameter, in which case the function will 33 | show the matrix_control values to be used and then stop. 34 | } 35 | \section{matrix_control list values}{ 36 | 37 | \describe{ 38 | \item{matrix_class}{A string that specifies the matrix 39 | class to use for matrix storage. The acceptable 40 | values are "dgCMatrix" and "BPCells". matrix_class 41 | is required.} 42 | \item{matrix_type}{A string that specifies whether to 43 | store the matrix values as single precision "floats" 44 | (matrix_type="float") or double precision "doubles" 45 | (matrix_type="double"). The default is "double". 46 | "matrix_type" is used only for BPCells class matrices.} 47 | \item{matrix_mode}{A string that specifies whether to 48 | store the BPCells class matrix in memory 49 | (matrix_mode="mem") or on disk (matrix_mode="dir"). 50 | "matrix_mode" is used only for BPCells class 51 | matrices. At this time, only "dir" is allowed.} 52 | \item{matrix_path}{A string that specifies the directory 53 | where the BPCells on-disk matrix data are stored in a 54 | sub-directory with a randomized name. The default is 55 | in the directory where R is running. "matrix_path" is 56 | used only for BPCells class matrices with 57 | matrix_mode="dir". For example, if matrix_path is set 58 | to "my_dir" Monocle3 will create a directory with a 59 | name that has the form "monocle.bpcells.*.tmp" in 60 | "my_dir". The asterisk represents a random string that 61 | makes the name unique.} 62 | \item{matrix_compress}{A logical that specifies whether 63 | to use bit-packing compression to store BPCells matrix 64 | values. Only the matrix indices are compressed for 65 | matrix_types "float" and "double". "matrix_compress" 66 | is used only for BPCells class matrices. The default is 67 | FALSE, which improves processing speed.} 68 | \item{matrix_buffer_size}{An integer that specifies how 69 | many items of data to buffer in memory before flushing 70 | to disk. This is used for matrix_class="BPCells" with 71 | matrix_mode="dir". The default is 8192L.} 72 | \item{matrix_bpcells_copy}{A logical that specifies 73 | whether the input BPCells matrix is to be copied. This 74 | is relevant only when the input matrix and the desired 75 | output matrix are the same; that is, have the same 76 | matrix_mode, matrix_path, matrix_compress, and 77 | matrix_buffer_size values. If matrix_bpcells_copy is 78 | TRUE, the queued operations are applied to a new 79 | on-disk copy of of the input matrix and the operation 80 | queue is emptied. If FALSE, the queued operations are 81 | not applied and the on-disk storage is unaltered.} 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /tests/testthat/test-evaluate_models.R: -------------------------------------------------------------------------------- 1 | context("evaluate_models") 2 | 3 | cds <- load_a549() 4 | cds <- estimate_size_factors(cds) 5 | test_that("evaluate_models() returns correct output for poisson models",{ 6 | test_cds = cds[rowData(cds)$gene_short_name == "ANGPTL4",] 7 | fit_m = fit_models(test_cds, model_formula_str = "~log_dose", expression_family = "poisson") 8 | evaluated_fit = suppressWarnings(evaluate_fits(fit_m)) 9 | expect_equal(evaluated_fit$null_deviance, 1135, tolerance=1e-3) 10 | expect_equal(evaluated_fit$df_null, 499) 11 | expect_equal(evaluated_fit$logLik, -803, tolerance=1e-3) 12 | expect_equal(evaluated_fit$AIC, 1610, tolerance=1e-3) 13 | expect_equal(evaluated_fit$BIC, NA_real_) 14 | expect_equal(evaluated_fit$deviance, 999, tolerance=1e-3) 15 | expect_equal(evaluated_fit$df_residual, 498) 16 | }) 17 | 18 | test_that("evaluate_models() returns correct output for quasipoisson models",{ 19 | test_cds = cds[rowData(cds)$gene_short_name == "ANGPTL4",] 20 | fit_m = fit_models(test_cds, model_formula_str = "~log_dose", expression_family = "quasipoisson") 21 | evaluated_fit = suppressWarnings(evaluate_fits(fit_m)) 22 | expect_equal(evaluated_fit$null_deviance, 1135, tolerance=1e-3) 23 | expect_equal(evaluated_fit$df_null, 499) 24 | expect_equal(evaluated_fit$logLik, NA) 25 | expect_equal(evaluated_fit$AIC, NA_real_) 26 | expect_equal(evaluated_fit$BIC, NA_real_) 27 | expect_equal(evaluated_fit$deviance, 999, tolerance=1e-3) 28 | expect_equal(evaluated_fit$df_residual, 498) 29 | }) 30 | 31 | ### FIXME: Need cases for binomial (binary) data 32 | 33 | test_that("evaluate_models() returns correct output for negative binomial models",{ 34 | test_cds = cds[rowData(cds)$gene_short_name == "ANGPTL4",] 35 | fit = fit_models(test_cds, model_formula_str = "~log_dose", expression_family = "negbinomial") 36 | evaluated_fit = suppressWarnings(evaluate_fits(fit)) 37 | expect_equal(evaluated_fit$null_deviance, 557, tolerance=1e-3) 38 | expect_equal(evaluated_fit$df_null, 499) 39 | expect_equal(evaluated_fit$logLik, -686, tolerance=1e-3) 40 | expect_equal(evaluated_fit$AIC, 1380, tolerance=1e-3) 41 | expect_equal(evaluated_fit$BIC, 1380, tolerance=1e-3) 42 | expect_equal(evaluated_fit$deviance, 472, tolerance=1e-1) 43 | expect_equal(evaluated_fit$df_residual, 497) 44 | }) 45 | 46 | test_that("evaluate_models() returns correct output for zero-inflated poisson models",{ 47 | test_cds = cds[rowData(cds)$gene_short_name == "ANGPTL4",] 48 | fit = fit_models(test_cds, model_formula_str = "~log_dose", expression_family = "zipoisson") 49 | evaluated_fit = suppressWarnings(evaluate_fits(fit)) 50 | expect_equal(evaluated_fit$null_deviance, NA_real_) 51 | expect_equal(evaluated_fit$df_null, 498) 52 | expect_equal(evaluated_fit$logLik, -748, tolerance=1e-3) 53 | expect_equal(evaluated_fit$AIC, 1504, tolerance=1e-3) 54 | expect_equal(evaluated_fit$BIC, 1504, tolerance=1e-3) 55 | expect_equal(evaluated_fit$deviance, NA_real_) 56 | expect_equal(evaluated_fit$df_residual, 496) 57 | }) 58 | 59 | 60 | test_that("evaluate_models() returns correct output for zero-inflated negative binomial models",{ 61 | test_cds = cds[rowData(cds)$gene_short_name == "ANGPTL4",] 62 | fit = fit_models(test_cds, model_formula_str = "~log_dose", expression_family = "zinegbinomial") 63 | evaluated_fit = suppressWarnings(evaluate_fits(fit)) 64 | expect_equal(evaluated_fit$null_deviance, NA_real_) 65 | expect_equal(evaluated_fit$df_null, 498) 66 | expect_equal(evaluated_fit$logLik, -689, tolerance=1e-3) 67 | expect_equal(evaluated_fit$AIC, 1387, tolerance=1e-3) 68 | expect_equal(evaluated_fit$BIC, 1387, tolerance=1e-3) 69 | expect_equal(evaluated_fit$deviance, NA_real_) 70 | expect_equal(evaluated_fit$df_residual, 495) 71 | }) 72 | -------------------------------------------------------------------------------- /tests/testthat/test-load_cellranger_data.R: -------------------------------------------------------------------------------- 1 | # Contributed by Nigel Delaney with adaptations 2 | 3 | v3dname = "../testdata/cr3.0" 4 | v2dname = "../testdata/cr2.0" 5 | 6 | 7 | 8 | test_that("Cell Ranger 3.0 Filtered Data Loading", { 9 | cds = load_cellranger_data(v3dname) 10 | expect_equal(as.character(fData(cds)$gene_short_name[1]), "RP11-34P13.3") 11 | expect_equal(as.character(pData(cds)$barcode[1]), "AAAGTAGCACAGTCGC-1") 12 | expect_equal(dim(fData(cds)), c(3,2)) 13 | expect_is(cds, "cell_data_set") 14 | }) 15 | 16 | test_that("Cell Ranger 3.0 No Data Fails", { 17 | expect_error(load_cellranger_data(v3dname, barcode_filtered = FALSE)) 18 | }) 19 | 20 | test_that("Cell Ranger 2.0 Filtered Data Loading", { 21 | cds = load_cellranger_data(v2dname) 22 | expect_equal(as.character(fData(cds)$gene_short_name[1]), "MS4A1") 23 | expect_equal(as.character(pData(cds)$barcode[1]), "GAACCTGATGAACC-1") 24 | expect_equal(dim(fData(cds)), c(240,2)) 25 | expect_is(cds, "cell_data_set") 26 | }) 27 | 28 | test_that("Cell Ranger 2.0 No Data Fails", { 29 | expect_error(load_cellranger_data(v3dname, barcode_filtered = FALSE)) 30 | }) 31 | 32 | # Now make sure raw data works 33 | test_that("load_cellranger_matrix on 2.0 raw matrices", { 34 | # Copy the filtered data over and pretend it is unfiltered 35 | tmpdir = tempdir() 36 | odir = file.path(tmpdir, "outs", "raw_gene_bc_matrices", "hg19") 37 | odir2 = file.path(tmpdir, "outs", "filtered_gene_bc_matrices") 38 | dir.create(odir, recursive = TRUE) 39 | dir.create(odir2, recursive = TRUE) 40 | src = "../testdata/cr2.0/outs/filtered_gene_bc_matrices/hg19/" 41 | lapply(dir(src), function(p) file.copy(file.path(src, p), odir, recursive = TRUE)) 42 | cds = load_cellranger_data(tmpdir, barcode_filtered=FALSE) 43 | unlink(odir, recursive = TRUE) 44 | unlink(odir2, recursive = TRUE) 45 | expect_equal(as.character(fData(cds)$gene_short_name[1]), "MS4A1") 46 | expect_equal(as.character(pData(cds)$barcode[1]), "GAACCTGATGAACC-1") 47 | expect_equal(dim(fData(cds)), c(240,2)) 48 | expect_is(cds, "cell_data_set") 49 | }) 50 | 51 | test_that("load_cellranger_matrix on 3.0 raw matrices", { 52 | # Copy the filtered data over and pretend it is unfiltered 53 | tmpdir = tempdir() 54 | odir = file.path(tmpdir, "outs", "raw_feature_bc_matrix") 55 | odir2 = file.path(tmpdir, "outs", "filtered_feature_bc_matrix") 56 | dir.create(odir, recursive = TRUE) 57 | dir.create(odir2, recursive = TRUE) 58 | src = "../testdata/cr3.0/outs/filtered_feature_bc_matrix" 59 | lapply(dir(src), function(p) file.copy(file.path(src, p), odir, recursive = TRUE)) 60 | cds = load_cellranger_data(tmpdir, barcode_filtered=FALSE) 61 | unlink(odir, recursive = TRUE) 62 | unlink(odir2, recursive = TRUE) 63 | expect_equal(as.character(fData(cds)$gene_short_name[1]), "RP11-34P13.3") 64 | expect_equal(as.character(pData(cds)$barcode[1]), "AAAGTAGCACAGTCGC-1") 65 | expect_equal(dim(fData(cds)), c(3,2)) 66 | expect_is(cds, "cell_data_set") 67 | }) 68 | 69 | test_that("load_cellranger_matrix on 3.0 with genome", { 70 | cds = load_cellranger_data(v3dname, genome="hg19") 71 | expect_equal(as.character(fData(cds)$gene_short_name[1]), "RP11-34P13.3") 72 | expect_equal(as.character(pData(cds)$barcode[1]), "AAAGTAGCACAGTCGC-1") 73 | expect_equal(dim(fData(cds)), c(3,2)) 74 | expect_is(cds, "cell_data_set") 75 | }) 76 | 77 | test_that("Cell Ranger 2.0 Filtered Data Loading with genome", { 78 | cds = load_cellranger_data(v2dname, genome="hg19") 79 | expect_equal(as.character(fData(cds)$gene_short_name[1]), "MS4A1") 80 | expect_equal(as.character(pData(cds)$barcode[1]), "GAACCTGATGAACC-1") 81 | expect_equal(dim(fData(cds)), c(240,2)) 82 | expect_is(cds, "cell_data_set") 83 | }) 84 | 85 | test_that("Cell Ranger 2.0 Filtered Data Loading fake genome", { 86 | expect_error(load_cellranger_data(v2dname, genome="donkey")) 87 | }) 88 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: monocle3 2 | Title: Clustering, Differential Expression, and Trajectory Analysis for 3 | Single-Cell RNA-Seq 4 | Version: 1.4.26 5 | Authors@R: c( 6 | person(given = "Hannah", 7 | family = "Pliner", 8 | role = c("aut"), 9 | email = "hpliner@uw.edu"), 10 | person(given = "Xiaojie", 11 | family = "Qiu", 12 | role = c("aut"), 13 | email = "xqiu@uw.edu"), 14 | person(given = "Cole", 15 | family = "Trapnell", 16 | role = c("aut"), 17 | email = "coletrap@uw.edu"), 18 | person(given = "Brent", 19 | family = "Ewing", 20 | role = c("cre"), 21 | email = "bge@uw.edu")) 22 | Description: Monocle 3 performs clustering, differential expression and 23 | trajectory analysis for single-cell expression experiments. It orders 24 | individual cells according to progress through a biological process, 25 | without knowing ahead of time which genes define progress through that 26 | process. Monocle 3 also performs differential expression analysis, 27 | clustering, visualization, and other useful tasks on single-cell expression 28 | data. It is designed to work with RNA-Seq data, but could be used with 29 | other types as well. 30 | biocViews: 31 | Software, 32 | SingleCell, 33 | RNASeq, 34 | ATACSeq, 35 | Normalization, 36 | Preprocessing, 37 | DimensionReduction, 38 | Visualization, 39 | QualityControl, 40 | Clustering, 41 | Classification, 42 | Annotation, 43 | GeneExpression, 44 | DifferentialExpression 45 | License: MIT + file LICENSE 46 | Encoding: UTF-8 47 | LazyData: false 48 | Roxygen: list(markdown = TRUE) 49 | RoxygenNote: 7.3.2 50 | LinkingTo: 51 | Rcpp 52 | Depends: 53 | R (>= 4.0.0), 54 | Biobase, 55 | SingleCellExperiment 56 | Imports: 57 | assertthat (>= 0.2.1), 58 | batchelor, 59 | BiocGenerics (>= 0.28.0), 60 | BiocParallel, 61 | BPCells, 62 | DelayedArray (>= 0.8.0), 63 | DelayedMatrixStats (>= 1.4.0), 64 | digest (>= 0.6.28), 65 | dplyr (>= 0.8.0.1), 66 | future (>= 1.23.0), 67 | ggdist (>= 3.3.0), 68 | ggforce (>= 0.4.1), 69 | ggplot2 (>= 3.1.1), 70 | ggrastr, 71 | ggrepel (>= 0.8.1), 72 | grr, 73 | HDF5Array, 74 | igraph (>= 1.5.0), 75 | irlba (>= 2.3.3), 76 | leidenbase (>= 0.1.25), 77 | limma (>= 3.38.3), 78 | lme4 (>= 1.1-27), 79 | lmtest (>= 0.9-36), 80 | MASS (>= 7.3-51.4), 81 | Matrix (>= 1.2-17), 82 | methods, 83 | openssl, 84 | pbapply (>= 1.4-0), 85 | pbmcapply (>= 1.4.1), 86 | pheatmap, 87 | plotly (>= 4.9.0), 88 | plyr (>= 1.8.4), 89 | proxy (>= 0.4-23), 90 | pscl (>= 1.5.2), 91 | purrr (>= 0.3.2), 92 | RANN (>= 2.6.1), 93 | RColorBrewer, 94 | Rcpp (>= 1.0.1), 95 | reshape2 (>= 1.4.3), 96 | rsample (>= 0.0.5), 97 | RhpcBLASctl, 98 | RcppAnnoy, 99 | RcppHNSW (>= 0.3.0), 100 | Rtsne (>= 0.15), 101 | S4Vectors, 102 | sf, 103 | shiny, 104 | slam (>= 0.1-45), 105 | spdep (>= 1.1-2), 106 | speedglm (>= 0.3-2), 107 | stats, 108 | stringr (>= 1.4.0), 109 | SummarizedExperiment (>= 1.11.5), 110 | utils, 111 | uwot (>= 0.1.8), 112 | tibble (>= 2.1.1), 113 | tidyr (>= 0.8.3), 114 | viridis (>= 0.5.1) 115 | Suggests: 116 | knitr, 117 | pryr (>= 0.1.4), 118 | rmarkdown, 119 | scran, 120 | spelling, 121 | testthat (>= 2.1.0) 122 | Remotes: 123 | github::bnprks/BPCells/r, 124 | github::cole-trapnell-lab/speedglm 125 | VignetteBuilder: knitr 126 | Language: en-US 127 | NeedsCompilation: yes 128 | Packaged: 2022-05-10 17:21:53 UTC; brent 129 | Maintainer: Brent Ewing 130 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citEntry(entry="article", 2 | title = "The dynamics and regulators of cell fate decisions are revealed by pseudo-temporal ordering of single cells", 3 | author = personList( as.person("Cole Trapnell"), 4 | as.person("Davide Cacchiarelli"), 5 | as.person("Jonna Grimsby"), 6 | as.person("Prapti Pokharel"), 7 | as.person("Shuqiang Li"), 8 | as.person("Michael Morse"), 9 | as.person("Niall J. Lennon"), 10 | as.person("Kenneth J. Livak"), 11 | as.person("Tarjei S. Mikkelsen"), 12 | as.person("John L. Rinn")), 13 | year = 2014, 14 | journal = "Nature Biotechnology", 15 | textVersion = 16 | paste("Cole Trapnell and Davide Cacchiarelli et al (2014):", 17 | "The dynamics and regulators of cell fate decisions are revealed by pseudo-temporal ordering of single cells.", 18 | "Nature Biotechnology" ) ) 19 | 20 | citEntry(entry="article", 21 | title = "Single-cell mRNA quantification and differential analysis with Census", 22 | author = personList( as.person("Xiaojie Qiu"), 23 | as.person("Andrew Hill"), 24 | as.person("Jonathan Packer"), 25 | as.person("Dejun Lin"), 26 | as.person("Yi-An Ma"), 27 | as.person("Cole Trapnell")), 28 | year = 2017, 29 | journal = "Nature Methods", 30 | textVersion = 31 | paste("Xiaojie Qiu et al (2017):", 32 | "Single-cell mRNA quantification and differential analysis with Census.", 33 | "Nature Methods" ) ) 34 | 35 | citEntry(entry="article", 36 | title = "Reverse graph embedding resolves complex single-cell developmental trajectories.", 37 | author = personList( as.person("Xiaojie Qiu"), 38 | as.person("Qi Mao"), 39 | as.person("Ying Tang"), 40 | as.person("Li Wang"), 41 | as.person("Raghav Chawla"), 42 | as.person("Hannah Pliner"), 43 | as.person("Cole Trapnell")), 44 | year = 2017, 45 | journal = "BioRxiv", 46 | textVersion = 47 | paste("Xiaojie Qiu et al (2017):", 48 | "Reverse graph embedding resolves complex single-cell developmental trajectories.", 49 | "Nature Methods" ) ) 50 | 51 | citEntry(entry="article", 52 | title = "The dynamics and regulators of cell fate decisions are revealed by pseudo-temporal ordering of single cells", 53 | author = personList( as.person("Junyue Cao"), 54 | as.person("Malte Spielmann"), 55 | as.person("Xiaojie Qiu"), 56 | as.person("Xingfan Huang"), 57 | as.person("Daniel M. Ibrahim"), 58 | as.person("Andrew J. Hill"), 59 | as.person("Fan Zhang"), 60 | as.person("Stefan Mundlos"), 61 | as.person("Lena Christiansen"), 62 | as.person("Frank J. Steemers"), 63 | as.person("Cole Trapnell"), 64 | as.person("Jay Shendure")), 65 | year = 2019, 66 | journal = "Nature", 67 | textVersion = 68 | paste("Junyue Cao, Malte Spielmann et al (2019):", 69 | "The single-cell transcriptional landscape of mammalian organogenesis.", 70 | "Nature" ) ) 71 | 72 | -------------------------------------------------------------------------------- /man/preprocess_cds.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/preprocess_cds.R 3 | \name{preprocess_cds} 4 | \alias{preprocess_cds} 5 | \title{Preprocess a cds to prepare for trajectory inference} 6 | \usage{ 7 | preprocess_cds( 8 | cds, 9 | method = c("PCA", "LSI"), 10 | num_dim = 50, 11 | norm_method = c("log", "size_only", "none"), 12 | use_genes = NULL, 13 | pseudo_count = NULL, 14 | scaling = TRUE, 15 | verbose = FALSE, 16 | build_nn_index = FALSE, 17 | nn_control = list() 18 | ) 19 | } 20 | \arguments{ 21 | \item{cds}{the cell_data_set upon which to perform this operation} 22 | 23 | \item{method}{a string specifying the initial dimension method to use, 24 | currently either "PCA" or "LSI". For "LSI" (latent semantic indexing), it 25 | converts the (sparse) expression matrix into a tf-idf matrix and then 26 | performs SVD to decompose the gene expression / cells into certain 27 | modules / topics. Default is "PCA".} 28 | 29 | \item{num_dim}{the dimensionality of the reduced space.} 30 | 31 | \item{norm_method}{Determines how to transform expression values prior to 32 | reducing dimensionality. Options are "log", "size_only", and "none". 33 | Default is "log". Users should only use "none" if they are confident that 34 | their data is already normalized.} 35 | 36 | \item{use_genes}{NULL or a list of gene IDs. If a list of gene IDs, only 37 | this subset of genes is used for dimensionality reduction. Default is 38 | NULL.} 39 | 40 | \item{pseudo_count}{NULL or the amount to increase expression values before 41 | normalization and dimensionality reduction. If NULL (default), a 42 | pseudo_count of 1 is added for log normalization and 0 is added for size 43 | factor only normalization.} 44 | 45 | \item{scaling}{When this argument is set to TRUE (default), it will scale 46 | each gene before running trajectory reconstruction. Relevant for 47 | method = PCA only.} 48 | 49 | \item{verbose}{Whether to emit verbose output during dimensionality 50 | reduction} 51 | 52 | \item{build_nn_index}{logical When this argument is set to TRUE, 53 | preprocess_cds builds and stores the nearest neighbor index from the 54 | reduced dimension matrix for later use. Default is FALSE.} 55 | 56 | \item{nn_control}{An optional list of parameters used to make the nearest 57 | neighbor index. See the set_nn_control help for detailed information.} 58 | } 59 | \value{ 60 | an updated cell_data_set object 61 | } 62 | \description{ 63 | Most analyses (including trajectory inference, and clustering) 64 | in Monocle3, require various normalization and preprocessing steps. 65 | \code{preprocess_cds} executes and stores these preprocessing steps. 66 | 67 | Specifically, depending on the options selected, \code{preprocess_cds} first 68 | normalizes the data by log and size factor to address depth differences, or 69 | by size factor only. Next, \code{preprocess_cds} calculates a lower 70 | dimensional space that will be used as the input for further dimensionality 71 | reduction like tSNE and UMAP. 72 | } 73 | \examples{ 74 | \donttest{ 75 | cell_metadata <- readRDS(system.file('extdata', 76 | 'worm_embryo/worm_embryo_coldata.rds', 77 | package='monocle3')) 78 | gene_metadata <- readRDS(system.file('extdata', 79 | 'worm_embryo/worm_embryo_rowdata.rds', 80 | package='monocle3')) 81 | expression_matrix <- readRDS(system.file('extdata', 82 | 'worm_embryo/worm_embryo_expression_matrix.rds', 83 | package='monocle3')) 84 | cds <- new_cell_data_set(expression_data=expression_matrix, 85 | cell_metadata=cell_metadata, 86 | gene_metadata=gene_metadata) 87 | cds <- preprocess_cds(cds) 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /man/sparse_prcomp_irlba.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pca.R 3 | \name{sparse_prcomp_irlba} 4 | \alias{sparse_prcomp_irlba} 5 | \title{Principal Components Analysis} 6 | \usage{ 7 | sparse_prcomp_irlba( 8 | x, 9 | n = 3, 10 | retx = TRUE, 11 | center = TRUE, 12 | scale. = FALSE, 13 | verbose = FALSE, 14 | ... 15 | ) 16 | } 17 | \arguments{ 18 | \item{x}{a numeric or complex matrix (or data frame) which provides the data 19 | for the principal components analysis.} 20 | 21 | \item{n}{integer number of principal component vectors to return, must be 22 | less than \code{min(dim(x))}.} 23 | 24 | \item{retx}{a logical value indicating whether the rotated variables should 25 | be returned.} 26 | 27 | \item{center}{a logical value indicating whether the variables should be 28 | shifted to be zero centered. Alternately, a centering vector of length 29 | equal the number of columns of \code{x} can be supplied.} 30 | 31 | \item{scale.}{a logical value indicating whether the variables should be 32 | scaled to have unit variance before the analysis takes place. The default 33 | is \code{FALSE} for consistency with S, but scaling is often advisable. 34 | Alternatively, a vector of length equal the number of columns of \code{x} 35 | can be supplied. 36 | 37 | The value of \code{scale} determines how column scaling is performed 38 | (after centering). If \code{scale} is a numeric vector with length equal 39 | to the number of columns of \code{x}, then each column of \code{x} is 40 | divided by the corresponding value from \code{scale}. If \code{scale} is 41 | \code{TRUE} then scaling is done by dividing the (centered) columns of 42 | \code{x} by their standard deviations if \code{center=TRUE}, and the root 43 | mean square otherwise. If \code{scale} is \code{FALSE}, no scaling is done. 44 | See \code{\link{scale}} for more details.} 45 | 46 | \item{verbose}{a logical value that determines whether or not the 47 | function writes diagnostic information.} 48 | 49 | \item{...}{additional arguments passed to \code{\link{irlba}}.} 50 | } 51 | \value{ 52 | A list with class "prcomp" containing the following components: 53 | \itemize{ 54 | \item{sdev} {the standard deviations of the principal components (i.e., 55 | the square roots of the eigenvalues of the covariance/correlation 56 | matrix, though the calculation is actually done with the singular 57 | values of the data matrix).} 58 | \item{rotation} {the matrix of variable loadings (i.e., a matrix whose 59 | columns contain the eigenvectors).} 60 | \item {x} {if \code{retx} is \code{TRUE} the value of the rotated data 61 | (the centered (and scaled if requested) data multiplied by the 62 | \code{rotation} matrix) is returned. Hence, \code{cov(x)} is the 63 | diagonal matrix \code{diag(sdev^2)}.} 64 | \item{center, scale} {the centering and scaling used, or \code{FALSE}.} 65 | } 66 | } 67 | \description{ 68 | Efficient computation of a truncated principal components analysis of a 69 | given data matrix using an implicitly restarted Lanczos method from the 70 | \code{\link{irlba}} package. 71 | } 72 | \note{ 73 | The signs of the columns of the rotation matrix are arbitrary, and so may 74 | differ between different programs for PCA, and even between different builds 75 | of R. 76 | 77 | NOTE DIFFERENCES WITH THE DEFAULT \code{\link{prcomp}} FUNCTION! The 78 | \code{tol} truncation argument found in \code{prcomp} is not supported. In 79 | place of the truncation tolerance in the original function, the 80 | \code{prcomp_irlba} function has the argument \code{n} explicitly giving 81 | the number of principal components to return. A warning is generated if the 82 | argument \code{tol} is used, which is interpreted differently between the 83 | two functions. 84 | } 85 | \examples{ 86 | \dontrun{ 87 | set.seed(1) 88 | x <- matrix(rnorm(200), nrow=20) 89 | p1 <- irlba::prcomp_irlba(x, n=3) 90 | summary(p1) 91 | 92 | # Compare with 93 | p2 <- prcomp(x, tol=0.7) 94 | summary(p2)} 95 | 96 | } 97 | \seealso{ 98 | \code{\link{prcomp}} 99 | } 100 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export("fData<-") 4 | export("pData<-") 5 | export("principal_graph<-") 6 | export("principal_graph_aux<-") 7 | export(aggregate_gene_expression) 8 | export(align_cds) 9 | export(align_transform) 10 | export(choose_cells) 11 | export(choose_graph_segments) 12 | export(clear_cds_slots) 13 | export(cluster_cells) 14 | export(clusters) 15 | export(coefficient_table) 16 | export(combine_cds) 17 | export(compare_models) 18 | export(convert_counts_matrix) 19 | export(counts_row_order) 20 | export(detect_genes) 21 | export(estimate_size_factors) 22 | export(evaluate_fits) 23 | export(exprs) 24 | export(fData) 25 | export(find_gene_modules) 26 | export(fit_models) 27 | export(fix_missing_cell_labels) 28 | export(generate_garnett_marker_file) 29 | export(get_citations) 30 | export(graph_test) 31 | export(identity_table) 32 | export(learn_graph) 33 | export(load_a549) 34 | export(load_cellranger_data) 35 | export(load_mm_data) 36 | export(load_monocle_objects) 37 | export(load_mtx_data) 38 | export(load_transform_models) 39 | export(load_worm_embryo) 40 | export(load_worm_l2) 41 | export(make_cds_nn_index) 42 | export(make_nn_index) 43 | export(model_predictions) 44 | export(new_cell_data_set) 45 | export(normalized_counts) 46 | export(order_cells) 47 | export(pData) 48 | export(partitions) 49 | export(plot_cells) 50 | export(plot_cells_3d) 51 | export(plot_cells_per_sample_and_perturbation) 52 | export(plot_genes_by_group) 53 | export(plot_genes_hybrid) 54 | export(plot_genes_in_pseudotime) 55 | export(plot_genes_violin) 56 | export(plot_mito_umi_per_cell) 57 | export(plot_pc_variance_explained) 58 | export(plot_percent_cells_positive) 59 | export(plot_umi_per_cell) 60 | export(plot_umi_per_cell_and_perturbation) 61 | export(preprocess_cds) 62 | export(preprocess_transform) 63 | export(principal_graph) 64 | export(principal_graph_aux) 65 | export(pseudotime) 66 | export(reduce_dimension) 67 | export(reduce_dimension_transform) 68 | export(save_monocle_objects) 69 | export(save_transform_models) 70 | export(search_cds_nn_index) 71 | export(search_nn_index) 72 | export(search_nn_matrix) 73 | export(set_cds_nn_index) 74 | export(set_cds_row_order_matrix) 75 | export(set_matrix_control) 76 | export(size_factors) 77 | export(top_markers) 78 | export(transfer_cell_labels) 79 | exportClasses(cell_data_set) 80 | exportMethods("counts<-") 81 | exportMethods("fData<-") 82 | exportMethods("pData<-") 83 | exportMethods("principal_graph<-") 84 | exportMethods("principal_graph_aux<-") 85 | exportMethods(clusters) 86 | exportMethods(counts_row_order) 87 | exportMethods(exprs) 88 | exportMethods(fData) 89 | exportMethods(pData) 90 | exportMethods(partitions) 91 | exportMethods(principal_graph) 92 | exportMethods(principal_graph_aux) 93 | exportMethods(pseudotime) 94 | exportMethods(saveRDS) 95 | import(ggplot2) 96 | importClassesFrom(S4Vectors,List) 97 | importFrom(Biobase,multiassign) 98 | importFrom(Biobase,package.version) 99 | importFrom(BiocGenerics,"counts<-") 100 | importFrom(BiocGenerics,density) 101 | importFrom(S4Vectors,elementMetadata) 102 | importFrom(S4Vectors,getListElement) 103 | importFrom(SingleCellExperiment,"reducedDim<-") 104 | importFrom(SingleCellExperiment,"reducedDims<-") 105 | importFrom(SingleCellExperiment,SingleCellExperiment) 106 | importFrom(SingleCellExperiment,colData) 107 | importFrom(SingleCellExperiment,counts) 108 | importFrom(SingleCellExperiment,reducedDim) 109 | importFrom(SingleCellExperiment,reducedDims) 110 | importFrom(SingleCellExperiment,rowData) 111 | importFrom(SummarizedExperiment,"assays<-") 112 | importFrom(SummarizedExperiment,"colData<-") 113 | importFrom(SummarizedExperiment,"rowData<-") 114 | importFrom(SummarizedExperiment,Assays) 115 | importFrom(SummarizedExperiment,assays) 116 | importFrom(SummarizedExperiment,rowRanges) 117 | importFrom(dplyr,"%>%") 118 | importFrom(dplyr,n) 119 | importFrom(future,value) 120 | importFrom(igraph,dfs) 121 | importFrom(lme4,glmer) 122 | importFrom(plyr,".") 123 | importFrom(utils,packageVersion) 124 | useDynLib(monocle3, .registration = TRUE) 125 | -------------------------------------------------------------------------------- /man/bpcells_prcomp_irlba.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pca.R 3 | \name{bpcells_prcomp_irlba} 4 | \alias{bpcells_prcomp_irlba} 5 | \title{Principal Components Analysis on BPCells IterableMatrix} 6 | \usage{ 7 | bpcells_prcomp_irlba( 8 | x, 9 | n = 3, 10 | retx = TRUE, 11 | center = TRUE, 12 | scale. = FALSE, 13 | verbose = FALSE, 14 | ... 15 | ) 16 | } 17 | \arguments{ 18 | \item{x}{a numeric or complex matrix (or data frame) which provides the data 19 | for the principal components analysis.} 20 | 21 | \item{n}{integer number of principal component vectors to return, must be 22 | less than \code{min(dim(x))}.} 23 | 24 | \item{retx}{a logical value indicating whether the rotated variables should 25 | be returned.} 26 | 27 | \item{center}{a logical value indicating whether the variables should be 28 | shifted to be zero centered. Alternately, a centering vector of length 29 | equal the number of columns of \code{x} can be supplied.} 30 | 31 | \item{scale.}{a logical value indicating whether the variables should be 32 | scaled to have unit variance before the analysis takes place. The default 33 | is \code{FALSE} for consistency with S, but scaling is often advisable. 34 | Alternatively, a vector of length equal the number of columns of \code{x} 35 | can be supplied. 36 | 37 | The value of \code{scale} determines how column scaling is performed 38 | (after centering). If \code{scale} is a numeric vector with length equal 39 | to the number of columns of \code{x}, then each column of \code{x} is 40 | divided by the corresponding value from \code{scale}. If \code{scale} is 41 | \code{TRUE} then scaling is done by dividing the (centered) columns of 42 | \code{x} by their standard deviations if \code{center=TRUE}, and the root 43 | mean square otherwise. If \code{scale} is \code{FALSE}, no scaling is done. 44 | See \code{\link{scale}} for more details.} 45 | 46 | \item{verbose}{a logical value that determines whether or not the 47 | function writes diagnostic information.} 48 | 49 | \item{...}{additional arguments passed to \code{\link{irlba}}.} 50 | } 51 | \value{ 52 | A list with class "prcomp" containing the following components: 53 | \itemize{ 54 | \item{sdev} {the standard deviations of the principal components (i.e., 55 | the square roots of the eigenvalues of the covariance/correlation 56 | matrix, though the calculation is actually done with the singular 57 | values of the data matrix).} 58 | \item{rotation} {the matrix of variable loadings (i.e., a matrix whose 59 | columns contain the eigenvectors).} 60 | \item {x} {if \code{retx} is \code{TRUE} the value of the rotated data 61 | (the centered (and scaled if requested) data multiplied by the 62 | \code{rotation} matrix) is returned. Hence, \code{cov(x)} is the 63 | diagonal matrix \code{diag(sdev^2)}.} 64 | \item{center, scale} {the centering and scaling used, or \code{FALSE}.} 65 | } 66 | } 67 | \description{ 68 | Efficient computation of a truncated principal components analysis of a 69 | given data matrix using an implicitly restarted Lanczos method from the 70 | \code{\link{irlba}} package. 71 | } 72 | \note{ 73 | The signs of the columns of the rotation matrix are arbitrary, and so may 74 | differ between different programs for PCA, and even between different builds 75 | of R. 76 | 77 | NOTE DIFFERENCES WITH THE DEFAULT \code{\link{prcomp}} FUNCTION! The 78 | \code{tol} truncation argument found in \code{prcomp} is not supported. In 79 | place of the truncation tolerance in the original function, the 80 | \code{prcomp_irlba} function has the argument \code{n} explicitly giving 81 | the number of principal components to return. A warning is generated if the 82 | argument \code{tol} is used, which is interpreted differently between the 83 | two functions. 84 | } 85 | \examples{ 86 | \dontrun{ 87 | set.seed(1) 88 | x <- matrix(rnorm(200), nrow=20) 89 | p1 <- irlba::prcomp_irlba(x, n=3) 90 | summary(p1) 91 | 92 | # Compare with 93 | p2 <- prcomp(x, tol=0.7) 94 | summary(p2)} 95 | 96 | } 97 | \seealso{ 98 | \code{\link{prcomp}} 99 | } 100 | --------------------------------------------------------------------------------