truecell 1.2.0__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {truecell-1.2.0 → truecell-2.1.0}/.claude/skills/README.md +1 -1
- {truecell-1.2.0 → truecell-2.1.0}/.claude/skills/truecell/SKILL.md +22 -11
- {truecell-1.2.0 → truecell-2.1.0}/.claude/skills/truecell/reference/api-map.md +81 -41
- {truecell-1.2.0 → truecell-2.1.0}/.claude/skills/truecell/reference/object-model.md +35 -3
- {truecell-1.2.0 → truecell-2.1.0}/CHANGELOG.md +759 -0
- truecell-1.2.0/README.md → truecell-2.1.0/PKG-INFO +187 -36
- truecell-1.2.0/PKG-INFO → truecell-2.1.0/README.md +111 -110
- {truecell-1.2.0 → truecell-2.1.0}/ROADMAP.md +79 -11
- {truecell-1.2.0 → truecell-2.1.0}/docs/tutorials/README.md +143 -71
- {truecell-1.2.0 → truecell-2.1.0}/docs/tutorials/benchmark/README.md +23 -11
- {truecell-1.2.0 → truecell-2.1.0}/pyproject.toml +18 -14
- truecell-2.1.0/tests/_layout.py +373 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/conftest.py +1 -1
- truecell-2.1.0/tests/data/loader_r_reference.json +154 -0
- truecell-2.1.0/tests/data/loaders/cosmx/Run1-polygons.csv +37 -0
- truecell-2.1.0/tests/data/loaders/cosmx/Run1_exprMat_file.csv +13 -0
- truecell-2.1.0/tests/data/loaders/cosmx/Run1_metadata_file.csv +10 -0
- truecell-2.1.0/tests/data/loaders/cosmx/Run1_tx_file.csv +25 -0
- truecell-2.1.0/tests/data/loaders/merscope/cell_boundaries/feature_data_0.hdf5 +0 -0
- truecell-2.1.0/tests/data/loaders/merscope/cell_boundaries/feature_data_1.hdf5 +0 -0
- truecell-2.1.0/tests/data/loaders/merscope/cell_boundaries/feature_data_2.hdf5 +0 -0
- truecell-2.1.0/tests/data/loaders/merscope/cell_by_gene.csv +8 -0
- truecell-2.1.0/tests/data/loaders/merscope/cell_metadata.csv +8 -0
- truecell-2.1.0/tests/data/loaders/xenium_csv/cell_feature_matrix/barcodes.tsv.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_csv/cell_feature_matrix/features.tsv.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_csv/cell_feature_matrix/matrix.mtx.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_csv/cells.csv.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_parquet/cell_feature_matrix/barcodes.tsv.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_parquet/cell_feature_matrix/features.tsv.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_parquet/cell_feature_matrix/matrix.mtx.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_parquet/cells.parquet +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_parquet_binary/cell_feature_matrix/barcodes.tsv.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_parquet_binary/cell_feature_matrix/features.tsv.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_parquet_binary/cell_feature_matrix/matrix.mtx.gz +0 -0
- truecell-2.1.0/tests/data/loaders/xenium_parquet_binary/cells.parquet +0 -0
- truecell-2.1.0/tests/data/make_analysis_defaults_reference.R +73 -0
- truecell-2.1.0/tests/data/make_deseq2_reference.R +187 -0
- truecell-2.1.0/tests/data/make_loader_bundles.py +261 -0
- truecell-2.1.0/tests/data/make_loader_r_reference.R +70 -0
- truecell-2.1.0/tests/data/make_modularity_reference.R +126 -0
- truecell-2.1.0/tests/data/make_negbinom_reference.R +45 -0
- truecell-2.1.0/tests/data/make_segmentation_centroid_reference.R +54 -0
- truecell-2.1.0/tests/data/make_select_integration_features_reference.R +60 -0
- truecell-2.1.0/tests/data/negbinom_reference_counts.json +1 -0
- truecell-2.1.0/tests/data/r_analysis_defaults.json +1 -0
- truecell-2.1.0/tests/data/r_deseq2_reference.json +1 -0
- truecell-2.1.0/tests/data/r_modularity_reference.json +1 -0
- truecell-2.1.0/tests/data/r_negbinom_reference.json +1 -0
- truecell-2.1.0/tests/data/r_segmentation_centroids.json +240 -0
- truecell-2.1.0/tests/data/r_select_integration_features.json +65 -0
- truecell-2.1.0/tests/data/seurat_formals.json +1291 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_analysis.py +1 -1
- truecell-2.1.0/tests/test_analysis_defaults.py +215 -0
- truecell-2.1.0/tests/test_anndata_compat.py +119 -0
- truecell-2.1.0/tests/test_anndata_spatial.py +528 -0
- truecell-2.1.0/tests/test_api_map_signatures.py +115 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_assay5.py +3 -3
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_bands.py +3 -3
- truecell-2.1.0/tests/test_benchmark_harness.py +101 -0
- truecell-2.1.0/tests/test_composition_samples.py +167 -0
- truecell-2.1.0/tests/test_constraints.py +62 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_de_bands.py +88 -36
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_de_parity.py +37 -21
- truecell-2.1.0/tests/test_default_parity.py +95 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_deseq2_pseudobulk.py +19 -13
- truecell-2.1.0/tests/test_deseq2_seurat_parity.py +341 -0
- truecell-2.1.0/tests/test_dim_plot_labels.py +454 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_docs.py +61 -4
- truecell-2.1.0/tests/test_docs_snippet.py +61 -0
- truecell-2.1.0/tests/test_feature_plot_cutoffs.py +151 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_find_clusters_resolutions.py +37 -12
- truecell-2.1.0/tests/test_generics.py +276 -0
- truecell-2.1.0/tests/test_integration_scoreboard.py +56 -0
- truecell-2.1.0/tests/test_layer_feature_alignment.py +128 -0
- truecell-2.1.0/tests/test_layout_helper.py +231 -0
- truecell-2.1.0/tests/test_legend_and_label_layout.py +174 -0
- truecell-2.1.0/tests/test_loaders_vs_seurat.py +113 -0
- truecell-2.1.0/tests/test_marker_ordering.py +121 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_markvariogram.py +16 -16
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_merscope_loader.py +15 -3
- truecell-2.1.0/tests/test_modularity_seurat_parity.py +297 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_multimodal_tutorial.py +114 -3
- truecell-2.1.0/tests/test_negbinom_glm_nb_parity.py +123 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_pbmc_handoff.py +93 -1
- truecell-2.1.0/tests/test_plot_group_order.py +251 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_plotting_layout.py +7 -3
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_plotting_theme.py +4 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_pseudobulk_conserved.py +1 -1
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_reductions_extra.py +69 -0
- truecell-2.1.0/tests/test_select_integration_features.py +87 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_seurat.py +59 -0
- truecell-2.1.0/tests/test_show_versions.py +206 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_spatial.py +1 -1
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_spatial_analysis.py +4 -4
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_spatially_variable_features.py +11 -11
- truecell-2.1.0/tests/test_subset_order.py +232 -0
- truecell-2.1.0/tests/test_tutorial_bootstrap.py +76 -0
- truecell-2.1.0/tests/test_tutorial_r_portability.py +39 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_tutorial_smoke.py +128 -10
- {truecell-1.2.0 → truecell-2.1.0}/truecell/__init__.py +5 -0
- truecell-2.1.0/truecell/_deseq2.py +248 -0
- truecell-2.1.0/truecell/_glm_nb.py +146 -0
- truecell-2.1.0/truecell/_modularity.py +569 -0
- truecell-2.1.0/truecell/_repel.py +357 -0
- truecell-2.1.0/truecell/_show_versions.py +486 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/_utils.py +50 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/anchors.py +89 -18
- {truecell-1.2.0 → truecell-2.1.0}/truecell/assay.py +18 -1
- {truecell-1.2.0 → truecell-2.1.0}/truecell/assay5.py +29 -17
- {truecell-1.2.0 → truecell-2.1.0}/truecell/clustering.py +179 -65
- truecell-2.1.0/truecell/compat/anndata.py +495 -0
- truecell-2.1.0/truecell/composition.py +200 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/dimreduc.py +18 -5
- {truecell-1.2.0 → truecell-2.1.0}/truecell/generics.py +111 -16
- {truecell-1.2.0 → truecell-2.1.0}/truecell/graph.py +5 -1
- {truecell-1.2.0 → truecell-2.1.0}/truecell/markers.py +191 -171
- truecell-2.1.0/truecell/mixins/key_mixin.py +52 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/mixscape.py +34 -4
- {truecell-1.2.0 → truecell-2.1.0}/truecell/module_score.py +24 -12
- {truecell-1.2.0 → truecell-2.1.0}/truecell/plotting.py +245 -74
- {truecell-1.2.0 → truecell-2.1.0}/truecell/reduction.py +1 -1
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/fov.py +14 -6
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/loaders.py +177 -73
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/segmentation.py +56 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/variable_features.py +32 -6
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/visium.py +20 -6
- {truecell-1.2.0 → truecell-2.1.0}/truecell/truecell.py +51 -8
- {truecell-1.2.0 → truecell-2.1.0}/truecell/umap.py +14 -6
- truecell-1.2.0/tests/test_anndata_compat.py +0 -40
- truecell-1.2.0/truecell/compat/anndata.py +0 -247
- truecell-1.2.0/truecell/composition.py +0 -100
- truecell-1.2.0/truecell/mixins/key_mixin.py +0 -30
- {truecell-1.2.0 → truecell-2.1.0}/.gitignore +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/LICENSE +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/docs/CHANGELOG.md +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/docs/ROADMAP.md +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/docs/assets/logo/README.md +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/data/find_neighbors_r_reference.json +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/data/prep_sct_r_reference.json +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_advanced_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_anchors_seurat_parity.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_annotations_resolve.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_assay.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_average_expression.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_bimod_de.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_cellcycle_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_command.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_datasets_loaders.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_dead_args.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_diet.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_dimreduc.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_dimreduc_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_find_neighbors_return_neighbor.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_graph.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_hashing_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_hto.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_hvf_column_names.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_integration.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_integration_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_lazy.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_lazy_bpcells_parity.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_lazy_pipeline.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_logmap.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_mapping.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_markers_prefilter.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_mast_de.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_mixscape.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_mixscape_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_module_score_performance.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_multimodal_wnn.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_multiseq.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_mvp_dispersion.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_neighbor.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_neighbors_graph_parity.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_new_features.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_object_model_typing.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_objects_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_packaging.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_pca_solver_parity.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_plotting_split.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_plotting_violin.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_prep_sct.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_pseudobulk_vs_r.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_reduction_feature_selection.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_refmap_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_sctransform_r_fidelity.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_sketch.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_sketch_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_spatial_parity.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_spatial_plots.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_spca_glmpca.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_svf_tutorial.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_transfer.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_tutorial_csv_precision.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_tutorial_marker_tables.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_typing_behaviour.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_visium_image.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/tests/test_visium_seurat_parity.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/_clara.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/_sparse.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/_types.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/aggregate.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/command.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/compat/__init__.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/datasets.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/diet.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/glmpca.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/hto.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/integration.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/io.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/jackstraw.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/lazy.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/logmap.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/mapping.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/mixins/__init__.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/multimodal.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/multiseq.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/neighbor.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/neighbors.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/preprocessing.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/py.typed +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/sctransform.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/sketch.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/__init__.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/analysis.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/base.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/centroids.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/spatial/molecules.py +0 -0
- {truecell-1.2.0 → truecell-2.1.0}/truecell/transfer.py +0 -0
|
@@ -14,7 +14,7 @@ and as context for any other model.
|
|
|
14
14
|
|---|---|
|
|
15
15
|
| [`truecell`](truecell/SKILL.md) | **Start here.** Install, the six API contracts, the canonical pipeline, routing. Bundles the full [API map](truecell/reference/api-map.md) and [object model](truecell/reference/object-model.md). |
|
|
16
16
|
| [`truecell-workflow`](truecell-workflow/SKILL.md) | A standard scRNA-seq run: QC thresholds, LogNormalize vs SCTransform, how many PCs, resolution, annotation. |
|
|
17
|
-
| [`truecell-differential-expression`](truecell-differential-expression/SKILL.md) | Marker genes, the
|
|
17
|
+
| [`truecell-differential-expression`](truecell-differential-expression/SKILL.md) | Marker genes, the nine `test_use` options, pseudobulk, conserved markers. |
|
|
18
18
|
| [`truecell-integration`](truecell-integration/SKILL.md) | Batch correction (Harmony/CCA/RPCA), label transfer, reference mapping, and scoring whether it worked. |
|
|
19
19
|
| [`truecell-multimodal`](truecell-multimodal/SKILL.md) | CITE-seq + WNN, cell hashing, pooled CRISPR (Mixscape). Includes the CLR `margin` rule. |
|
|
20
20
|
| [`truecell-spatial`](truecell-spatial/SKILL.md) | Xenium / Visium / CosMx / MERSCOPE, niches, spatially variable features, spatial plots. |
|
|
@@ -7,18 +7,18 @@ description: Use when writing, reading, debugging or reviewing Python single-cel
|
|
|
7
7
|
|
|
8
8
|
`truecell` is a Python port of [Seurat](https://satijalab.org/seurat/) v5 — the same
|
|
9
9
|
data structures and the same algorithms, checked against R Seurat 5.5.1 test by
|
|
10
|
-
test.
|
|
10
|
+
test. Python **3.12+**, MIT; `truecell.__version__` is the installed release.
|
|
11
11
|
|
|
12
12
|
- Docs: <https://genomicai.github.io/truecell/> · Repo: <https://github.com/GenomicAI/truecell>
|
|
13
|
-
-
|
|
14
|
-
(see contract 6 below).
|
|
13
|
+
- 115 public names in `truecell.__all__`, all importable from the package root.
|
|
14
|
+
Most of the generics are not among them (see contract 6 below).
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
17
|
pip install truecell # core: objects, preprocessing, PCA, markers
|
|
18
18
|
pip install "truecell[analysis]" # + clustering, UMAP, plotting ← the usual one
|
|
19
19
|
pip install "truecell[anndata]" # + AnnData interop
|
|
20
20
|
pip install "truecell[integration]" # + Harmony (harmonypy)
|
|
21
|
-
pip install "truecell[deseq2]" # +
|
|
21
|
+
pip install "truecell[deseq2]" # + DESeq2 (pydeseq2)
|
|
22
22
|
pip install "truecell[all]" # everything, incl. dev + docs tooling
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -81,8 +81,7 @@ truecell.features(pbmc) # AttributeError
|
|
|
81
81
|
|
|
82
82
|
Same for the loaders: `from truecell.io import read_10x`,
|
|
83
83
|
`from truecell.datasets import pbmc3k`, `from truecell.compat.anndata import as_anndata`.
|
|
84
|
-
|
|
85
|
-
that is not true.)
|
|
84
|
+
The API reference's generics and loader pages show these module paths.
|
|
86
85
|
|
|
87
86
|
## The canonical pipeline
|
|
88
87
|
|
|
@@ -129,7 +128,7 @@ Where results land: `pbmc.meta_data` (per-cell columns), `pbmc.reductions`
|
|
|
129
128
|
| Task | Skill |
|
|
130
129
|
|---|---|
|
|
131
130
|
| Standard scRNA-seq run, QC thresholds, how many PCs, resolution choice | `truecell-workflow` |
|
|
132
|
-
| Marker genes, the
|
|
131
|
+
| Marker genes, the nine DE tests, pseudobulk, conserved markers | `truecell-differential-expression` |
|
|
133
132
|
| Batch correction (Harmony/CCA/RPCA), label transfer, reference mapping | `truecell-integration` |
|
|
134
133
|
| CITE-seq / WNN, cell hashing demultiplexing, pooled CRISPR (Mixscape) | `truecell-multimodal` |
|
|
135
134
|
| Xenium / Visium / CosMx / MERSCOPE, niches, spatially variable features | `truecell-spatial` |
|
|
@@ -146,18 +145,30 @@ Where results land: `pbmc.meta_data` (per-cell columns), `pbmc.reductions`
|
|
|
146
145
|
`Assay5` / `DimReduc` / `Graph` containers, the generics, subsetting, layers,
|
|
147
146
|
AnnData interop.
|
|
148
147
|
|
|
148
|
+
## When it crashes
|
|
149
|
+
|
|
150
|
+
A segmentation fault, or a Jupyter kernel that dies, is compiled code failing.
|
|
151
|
+
The one reported so far was in `run_umap`, which runs numba code on parallel
|
|
152
|
+
threads. Rerun the script with `python -X faulthandler` to get the Python line,
|
|
153
|
+
and put `truecell.show_versions()`'s output in the report. It records numba's
|
|
154
|
+
threading layer and the OpenMP runtimes loaded, and warns about known causes.
|
|
155
|
+
The workaround to try first is `NUMBA_THREADING_LAYER=workqueue`, set before
|
|
156
|
+
anything imports numba. Details: <https://genomicai.github.io/truecell/troubleshooting/>.
|
|
157
|
+
|
|
149
158
|
## Known, deliberate differences from Seurat
|
|
150
159
|
|
|
151
160
|
Not bugs; do not "fix" them, and do not report them as regressions.
|
|
152
161
|
|
|
153
|
-
- **
|
|
154
|
-
|
|
162
|
+
- **Seurat's own clustering depends on the processor when edge weights tie exactly.**
|
|
163
|
+
`find_clusters` is Seurat's optimiser and gives its labels on the same graph, but
|
|
164
|
+
Seurat built for arm64 fuses a multiply-add that flips near-tied moves; truecell
|
|
165
|
+
follows the x86_64 build. PBMC 3k's SNN graph is unaffected.
|
|
155
166
|
- **Variable-feature selection jitters at the boundary.** 1,998 of 2,000 genes
|
|
156
167
|
shared on PBMC 3k; the two that swap sit at ranks ~1916–2016 where
|
|
157
168
|
standardized variances agree to three decimals.
|
|
158
169
|
- **Anything with an RNG differs by its RNG and only by that.**
|
|
159
|
-
`add_module_score` draws control genes at random (
|
|
160
|
-
Pearson ≥ 0.
|
|
170
|
+
`add_module_score` draws control genes at random (95.9 % phase concordance,
|
|
171
|
+
Pearson ≥ 0.997 on the scores); `jack_straw` permutes.
|
|
161
172
|
- **truecell's neighbour search is exact; Seurat's default `annoy` is approximate.**
|
|
162
173
|
When comparing, pass `nn.method = "rann"` on the R side.
|
|
163
174
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# truecell API map
|
|
2
2
|
|
|
3
3
|
Every public function, with its real signature and its Seurat equivalent.
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
The signatures are the code's: `tests/test_api_map_signatures.py` checks each one
|
|
5
|
+
against it, parameter for parameter and default for default.
|
|
6
|
+
`seurat` / `obj` as the first parameter means a `Truecell` object.
|
|
6
7
|
|
|
7
8
|
**Read the return column.** `None` means the function mutates in place — see
|
|
8
9
|
contract 1 in the parent skill.
|
|
@@ -24,7 +25,8 @@ create_truecell_object(counts, assay="RNA", min_cells=0, min_features=0,
|
|
|
24
25
|
meta_data=None, use_v5=True) -> Truecell
|
|
25
26
|
create_assay_object(counts=None, data=None, min_cells=0, min_features=0,
|
|
26
27
|
feature_names=None, cell_names=None, key="rna_") -> Assay
|
|
27
|
-
create_assay5_object(
|
|
28
|
+
create_assay5_object(counts=None, data=None, min_cells=0, min_features=0,
|
|
29
|
+
feature_names=None, cell_names=None, key="rna_") -> Assay5
|
|
28
30
|
log_truecell_command(object_, func_name, params=None, assay=None, reduction=None) -> TruecellCommand
|
|
29
31
|
as_graph(x, cell_names=None, assay_used=None, weighted=True) -> Graph
|
|
30
32
|
```
|
|
@@ -44,19 +46,25 @@ from truecell.datasets import pbmc3k, pbmc8k, cbmc_citeseq, pbmc_hashing, thp1_e
|
|
|
44
46
|
ifnb, panc8, xenium_mouse_brain, visium_mouse_brain
|
|
45
47
|
pbmc3k(data_dir=None, force_download=False) -> (counts, genes, cells)
|
|
46
48
|
cbmc_citeseq(data_dir=None, force_download=False, species_prefix="HUMAN_")
|
|
47
|
-
xenium_mouse_brain(
|
|
48
|
-
visium_mouse_brain(
|
|
49
|
-
ifnb(data_dir=None)
|
|
49
|
+
xenium_mouse_brain(data_dir=None, force_download=False) -> Path # a directory, for the loaders
|
|
50
|
+
visium_mouse_brain(data_dir=None, force_download=False) -> Path
|
|
51
|
+
ifnb(data_dir=None) # ifnb and panc8 need `Rscript tutorials/export_seuratdata.R <name>` once
|
|
52
|
+
panc8(data_dir=None)
|
|
50
53
|
```
|
|
51
54
|
|
|
52
55
|
Everything caches to `~/.truecell_data/` (~770 MB for the full set).
|
|
53
56
|
|
|
54
57
|
```python
|
|
55
58
|
from truecell.compat.anndata import as_anndata, from_anndata
|
|
56
|
-
as_anndata(seurat, assay=None)
|
|
57
|
-
from_anndata(adata, assay="RNA", spatial_key="spatial", fov_key="fov"
|
|
59
|
+
as_anndata(seurat, assay=None, spatial_key="spatial", fov_key="fov")
|
|
60
|
+
from_anndata(adata, assay="RNA", spatial_key="spatial", fov_key="fov",
|
|
61
|
+
image_resolution="lowres") -> Truecell
|
|
58
62
|
```
|
|
59
63
|
|
|
64
|
+
Space goes both ways in Scanpy's layout: `obsm["spatial"]` (x, y per cell),
|
|
65
|
+
`obs["fov"]` (the image), `uns["spatial"][library]` (a `VisiumV2`'s image and scale
|
|
66
|
+
factors). `Segmentation.as_centroids()` is SeuratObject's `as(seg, "Centroids")`.
|
|
67
|
+
|
|
60
68
|
## Preprocessing
|
|
61
69
|
|
|
62
70
|
| Seurat | truecell | Returns |
|
|
@@ -104,16 +112,19 @@ sctransform(seurat, assay=None, new_assay_name="SCT", n_cells=5000, n_genes=2000
|
|
|
104
112
|
```python
|
|
105
113
|
run_pca(seurat, n_pcs=50, features=None, assay=None, reduction_name="pca",
|
|
106
114
|
reduction_key="PC_", seed=42, layer="scale.data") -> None
|
|
107
|
-
run_ica(seurat, nics=50,
|
|
108
|
-
|
|
115
|
+
run_ica(seurat, nics=50, features=None, assay=None, reduction_name="ica",
|
|
116
|
+
reduction_key="IC_", seed=42, layer="scale.data", max_iter=200) -> None
|
|
117
|
+
run_spca(seurat, graph, npcs=50, features=None, assay=None, reduction_name="spca",
|
|
118
|
+
reduction_key="SPC_", seed=42, layer="scale.data") -> None # graph is required
|
|
109
119
|
run_tsne(seurat, dims=None, reduction="pca", n_components=2, perplexity=30.0,
|
|
110
|
-
reduction_name="tsne", seed=42, assay=None) -> None
|
|
120
|
+
reduction_name="tsne", reduction_key="tSNE_", seed=42, assay=None) -> None
|
|
111
121
|
run_umap(seurat, dims=None, reduction="pca", graph=None, n_components=2,
|
|
112
|
-
n_neighbors=30, min_dist=0.3, metric="
|
|
113
|
-
reduction_key=
|
|
122
|
+
n_neighbors=30, min_dist=0.3, metric="cosine", reduction_name="umap",
|
|
123
|
+
reduction_key=None, seed=42, assay=None) -> None # key None: "umap" -> "umap_"
|
|
114
124
|
glm_pca(seurat, n_components=10, features=None, assay=None, reduction_name="glmpca",
|
|
115
|
-
family="poisson", layer="counts", max_iter=100,
|
|
116
|
-
learning_rate=0.1, theta=100.0, optimize_theta=True,
|
|
125
|
+
reduction_key="GLMPC_", family="poisson", layer="counts", max_iter=100,
|
|
126
|
+
tol=1e-4, penalty=1.0, learning_rate=0.1, theta=100.0, optimize_theta=True,
|
|
127
|
+
seed=42) -> None
|
|
117
128
|
jack_straw(seurat, reduction="pca", dims=20, num_replicate=100, prop_freq=0.01,
|
|
118
129
|
layer="scale.data", seed=42) -> JackStrawData
|
|
119
130
|
score_jackstraw(seurat, reduction="pca", dims=None, score_thresh=1e-5) -> np.ndarray
|
|
@@ -136,8 +147,9 @@ in `seurat.neighbors["<assay>.nn"]` and builds **no** graphs — Seurat's
|
|
|
136
147
|
for the graphs. Indices are 0-based where R's `Indices()` are 1-based.
|
|
137
148
|
|
|
138
149
|
```python
|
|
139
|
-
find_clusters(seurat, resolution=0.
|
|
140
|
-
|
|
150
|
+
find_clusters(seurat, resolution=0.8, algorithm=1, graph_name=None, random_seed=0,
|
|
151
|
+
n_iter=10, group_singletons=True, cluster_name=None, modularity_fxn=1,
|
|
152
|
+
n_start=10, optimizer="seurat", n_iterations=None) -> None
|
|
141
153
|
find_multi_modal_neighbors(seurat, reduction_list=("pca", "apca"), dims_list=None,
|
|
142
154
|
k_nn=20, l2_norm=True, knn_graph_name="wknn",
|
|
143
155
|
snn_graph_name="wsnn", knn_range=200, prune_snn=1/15,
|
|
@@ -147,8 +159,11 @@ find_multi_modal_neighbors(seurat, reduction_list=("pca", "apca"), dims_list=Non
|
|
|
147
159
|
- `find_neighbors` writes `graphs["{assay}_nn"]` and `graphs["{assay}_snn"]`.
|
|
148
160
|
- `find_clusters` reads `{assay}_snn` unless `graph_name=` is given, and writes
|
|
149
161
|
`meta_data["seurat_clusters"]` plus the active identity.
|
|
150
|
-
- `algorithm`: **1** = Louvain (default), **2** = Louvain multilevel
|
|
151
|
-
**
|
|
162
|
+
- `algorithm`: **1** = Louvain (default), **2** = Louvain with multilevel
|
|
163
|
+
refinement, **3** = smart local moving, **4** = Leiden. For 1–3,
|
|
164
|
+
`optimizer="seurat"` runs Seurat's own optimiser, so the same graph gives
|
|
165
|
+
Seurat's labels, and `optimizer="igraph"` runs the single igraph pass of
|
|
166
|
+
truecell 1.2. `n_iterations` is a deprecated alias of `n_iter`.
|
|
152
167
|
- `group_singletons=True` absorbs size-1 clusters into their best-connected
|
|
153
168
|
neighbour, as Seurat's `GroupSingletons` does.
|
|
154
169
|
|
|
@@ -156,17 +171,18 @@ find_multi_modal_neighbors(seurat, reduction_list=("pca", "apca"), dims_list=Non
|
|
|
156
171
|
|
|
157
172
|
```python
|
|
158
173
|
find_markers(seurat, ident_1, ident_2=None, assay=None, layer=None, test_use="wilcox",
|
|
159
|
-
only_pos=False, min_pct=0.
|
|
174
|
+
only_pos=False, min_pct=0.01, logfc_threshold=0.1, features=None,
|
|
160
175
|
latent_vars=None, sample_col=None, max_cells_per_ident=None,
|
|
161
176
|
random_seed=1) -> pd.DataFrame
|
|
162
177
|
find_all_markers(seurat, assay=None, layer=None, test_use="wilcox", only_pos=False,
|
|
163
|
-
min_pct=0.
|
|
178
|
+
min_pct=0.01, logfc_threshold=0.1, sample_col=None,
|
|
164
179
|
max_cells_per_ident=None, random_seed=1, return_thresh=0.01) -> pd.DataFrame
|
|
165
180
|
find_conserved_markers(seurat, ident_1, grouping_var, ident_2=None, assay=None,
|
|
166
|
-
layer=None, test_use="wilcox", only_pos=False, min_pct=0.
|
|
167
|
-
logfc_threshold=0.
|
|
181
|
+
layer=None, test_use="wilcox", only_pos=False, min_pct=0.01,
|
|
182
|
+
logfc_threshold=0.1, features=None) -> pd.DataFrame
|
|
168
183
|
aggregate_expression(seurat, group_by="ident", assays=None, features=None,
|
|
169
|
-
layer="counts", return_object=False
|
|
184
|
+
layer="counts", return_object=False,
|
|
185
|
+
normalization_method="LogNormalize", scale_factor=10000.0)
|
|
170
186
|
```
|
|
171
187
|
|
|
172
188
|
`test_use`: `wilcox` · `t` · `bimod` · `LR` · `negbinom` · `poisson` · `mast` · `deseq2` · `roc`.
|
|
@@ -183,9 +199,11 @@ run_harmony(seurat, group_by, reduction="pca", dims=None, reduction_name="harmon
|
|
|
183
199
|
nclust=None, max_iter_harmony=10, assay=None, seed=0) -> None
|
|
184
200
|
integrate_layers(seurat, method="harmony", orig_reduction="pca", new_reduction=None,
|
|
185
201
|
group_by=None, assay=None, **kwargs) -> None
|
|
186
|
-
find_integration_anchors(objects, anchor_features=
|
|
202
|
+
find_integration_anchors(objects, anchor_features=2000, reduction="cca", dims=30,
|
|
187
203
|
k_anchor=5, k_filter=200, k_score=30, reference=0,
|
|
188
204
|
layer="scale.data", seed=42) -> IntegrationAnchors
|
|
205
|
+
select_integration_features(objects, nfeatures=2000, assay=None,
|
|
206
|
+
fvf_nfeatures=2000) -> list[str]
|
|
189
207
|
integrate_data(anchors, new_assay="integrated", k_weight=100, sd_weight=1.0,
|
|
190
208
|
add_cell_ids=None, seed=42) # returns a NEW object
|
|
191
209
|
integrate_embeddings(anchors, reduction, new_reduction="integrated_dr",
|
|
@@ -211,7 +229,7 @@ required for every method.
|
|
|
211
229
|
add_module_score(seurat, features, pool=None, nbin=24, ctrl=100, name="Cluster",
|
|
212
230
|
assay=None, layer="data", seed=1, search=False)
|
|
213
231
|
cell_cycle_scoring(seurat, s_features=None, g2m_features=None, assay=None,
|
|
214
|
-
layer="data", set_ident=False, nbin=24, ctrl=
|
|
232
|
+
layer="data", set_ident=False, nbin=24, ctrl=None, seed=1)
|
|
215
233
|
CC_GENES # the Tirosh 2016 human S / G2M sets, used when the args are None
|
|
216
234
|
```
|
|
217
235
|
|
|
@@ -230,7 +248,7 @@ calc_perturb_sig(seurat, assay="RNA", features=None, layer="data", labels="gene"
|
|
|
230
248
|
nt_class="NT", split_by=None, num_neighbors=20, reduction="pca",
|
|
231
249
|
ndims=15, new_assay="PRTB")
|
|
232
250
|
run_mixscape(seurat, assay="PRTB", labels="gene", nt_class="NT", de_assay="RNA",
|
|
233
|
-
layer="data", min_de_genes=5, min_cells=5, logfc_threshold=0.25,
|
|
251
|
+
layer="scale.data", min_de_genes=5, min_cells=5, logfc_threshold=0.25,
|
|
234
252
|
min_pct=0.05, pval_cutoff=0.05, iter_num=10, prtb_type="KO",
|
|
235
253
|
new_class="mixscape_class", de_test="wilcox", seed=0, verbose=False)
|
|
236
254
|
mixscape_lda(seurat, labels="gene", nt_class="NT", assay="PRTB", de_assay="RNA",
|
|
@@ -242,13 +260,14 @@ mixscape_lda(seurat, labels="gene", nt_class="NT", assay="PRTB", de_assay="RNA",
|
|
|
242
260
|
## Spatial → `truecell-spatial`
|
|
243
261
|
|
|
244
262
|
```python
|
|
245
|
-
load_xenium(path, assay="Xenium", fov_column=None, project="Xenium",
|
|
263
|
+
load_xenium(path, assay="Xenium", fov="fov", fov_column=None, project="Xenium",
|
|
264
|
+
keep_controls=False)
|
|
246
265
|
load_visium(path, assay="Spatial", project="Visium", image=True,
|
|
247
266
|
image_resolution="lowres", filter_by_tissue=True, slice_name="slice1")
|
|
248
|
-
load_cosmx(path, expr_file=None, meta_file=None, assay="Nanostring",
|
|
249
|
-
fov_column=
|
|
250
|
-
load_merscope(path, expr_file=None, meta_file=None, assay="Vizgen",
|
|
251
|
-
fov_column=
|
|
267
|
+
load_cosmx(path, expr_file=None, meta_file=None, assay="Nanostring", fov="fov",
|
|
268
|
+
fov_column=None, project="CosMx")
|
|
269
|
+
load_merscope(path, expr_file=None, meta_file=None, assay="Vizgen", fov="fov",
|
|
270
|
+
fov_column=None, project="MERSCOPE", keep_controls=False)
|
|
252
271
|
|
|
253
272
|
create_centroids(coords, nsides=0, radius=None, theta=None, assay="", key="centroids_")
|
|
254
273
|
create_segmentation(coords, assay="", key="segmentation_")
|
|
@@ -263,11 +282,15 @@ local_neighborhood(seurat, group_by, reference=None, k=10, image=None) -> pd.Dat
|
|
|
263
282
|
build_niche_assay(seurat, group_by, image=None, k=20, niches=4, assay_name="niche",
|
|
264
283
|
cluster=True, seed=0)
|
|
265
284
|
find_spatially_variable_features(seurat, features=None, method="moransi", k=10,
|
|
266
|
-
weights="inverse_square", assay=None, layer=
|
|
285
|
+
weights="inverse_square", assay=None, layer="scale.data",
|
|
267
286
|
image=None, r_metric=5.0, bandwidth=1.0) -> pd.DataFrame
|
|
268
|
-
composition_test(seurat, group_by, split_by, reference=None) -> pd.DataFrame
|
|
287
|
+
composition_test(seurat, group_by, split_by, reference=None, sample_col=None) -> pd.DataFrame
|
|
269
288
|
```
|
|
270
289
|
|
|
290
|
+
The loaders' `fov` names the one image they build, as Seurat's `fov` argument does
|
|
291
|
+
(`load_visium` calls it `slice_name`); `fov_column` splits the cells into one image
|
|
292
|
+
per value of that column instead.
|
|
293
|
+
|
|
271
294
|
Spatial classes: `SpatialImage`, `Centroids`, `Segmentation`, `Molecules`, `FOV`,
|
|
272
295
|
`VisiumV2`, `ScaleFactors`.
|
|
273
296
|
|
|
@@ -298,21 +321,38 @@ All 17 return a `matplotlib.figure.Figure`.
|
|
|
298
321
|
`spatial_dim_plot` · `spatial_feature_plot` · `plot_perturb_score` ·
|
|
299
322
|
`mixscape_heatmap`
|
|
300
323
|
|
|
324
|
+
## Diagnostics
|
|
325
|
+
|
|
326
|
+
```python
|
|
327
|
+
show_versions(as_dict=False) -> None # prints; as_dict=True returns the report instead
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
R's `sessionInfo()`, for a crash report: the platform (Rosetta 2, free-threaded),
|
|
331
|
+
the stack's versions and installers, numba's threading layer, and the OpenMP and
|
|
332
|
+
BLAS runtimes loaded. Its numba checks run in child processes.
|
|
333
|
+
|
|
301
334
|
## Generics (`truecell.generics.*`, not top-level)
|
|
302
335
|
|
|
303
336
|
`cells` · `features` · `idents` · `set_ident` · `stash_ident` · `rename_idents` ·
|
|
304
337
|
`reorder_ident` · `which_cells` · `fetch_data` · `layer_data` · `set_layer_data` ·
|
|
305
338
|
`layers` · `split_layers` · `join_layers` · `get_assay_data` · `set_assay_data` ·
|
|
306
339
|
`embeddings` · `loadings` · `set_loadings` · `stdev` · `variable_features` ·
|
|
307
|
-
`set_variable_features` · `
|
|
308
|
-
`set_default_layer` · `key` · `set_key` · `
|
|
309
|
-
`cast_assay` · `add_meta_data` · `rename_cells` · `
|
|
340
|
+
`set_variable_features` · `default_assay` · `set_default_assay` ·
|
|
341
|
+
`set_default_layer` · `key` · `set_key` · `assay_names` ·
|
|
342
|
+
`cast_assay` · `add_meta_data` · `rename_cells` · `calc_n` ·
|
|
310
343
|
`command` · `misc` / `set_misc` · `tool` / `set_tool` · `version` · `as_sparse` ·
|
|
311
|
-
`as_graph` · `as_neighbor` · `
|
|
344
|
+
`as_graph` · `as_neighbor` · `is_matrix_empty` ·
|
|
312
345
|
`simplify` · `distances` · `indices` ·
|
|
313
346
|
spatial: `boundaries` · `crop` · `overlay` · `radius` · `theta` · `get_image` ·
|
|
314
|
-
`get_molecules` · `get_tissue_coordinates` · `default_boundary` ·
|
|
315
|
-
`is_global` · `as_centroids`
|
|
316
|
-
|
|
347
|
+
`get_molecules` · `get_tissue_coordinates` · `default_boundary` ·
|
|
348
|
+
`is_global` · `as_centroids`
|
|
349
|
+
|
|
350
|
+
Each one is the object's own method, property or log reached by its R name, so
|
|
351
|
+
`g.set_ident(obj, cells, "x")` and `obj.set_ident(cells, "x")` are the same call.
|
|
352
|
+
What R has and the port does not is not stubbed here. The constructors
|
|
353
|
+
(`CreateSeuratObject`, `CreateFOV`, …) are the top-level `create_*` functions, which
|
|
354
|
+
take their input by keyword; `HVFInfo()` is the per-feature columns of
|
|
355
|
+
`assay.meta_data`; `Keys()`, `DefaultFOV()`, `DefaultDimReduc()`, `as.Seurat()` and
|
|
356
|
+
the S4 conversions have no counterpart.
|
|
317
357
|
|
|
318
358
|
See [`object-model.md`](object-model.md) for what each dispatches on.
|
|
@@ -57,11 +57,11 @@ obj[key] # assay by name
|
|
|
57
57
|
`obj.default_assay` is a property too.
|
|
58
58
|
|
|
59
59
|
`fetch_data` accepts metadata columns, feature names, and reduction columns
|
|
60
|
-
(`"PC_1"`, `"
|
|
60
|
+
(`"PC_1"`, `"umap_2"`) in one call, and returns plain numbers — not sparse
|
|
61
61
|
objects. Mixing them is the point:
|
|
62
62
|
|
|
63
63
|
```python
|
|
64
|
-
df = obj.fetch_data(["
|
|
64
|
+
df = obj.fetch_data(["umap_1", "umap_2", "seurat_clusters", "MS4A1"])
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
## Assay5 (the v5 layered assay)
|
|
@@ -100,7 +100,7 @@ truecell.generics.embeddings(dr) # cells × components
|
|
|
100
100
|
truecell.generics.loadings(dr, projected=False) # features × components
|
|
101
101
|
truecell.generics.stdev(dr) # per-component standard deviation
|
|
102
102
|
truecell.generics.features(dr, projected=False) # the features it was computed on
|
|
103
|
-
truecell.generics.key(dr) # "PC_", "
|
|
103
|
+
truecell.generics.key(dr) # "PC_", "umap_", …
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
A reduction records the features it **actually used**, not the ones requested —
|
|
@@ -153,6 +153,14 @@ obj = from_anndata(adata, assay="RNA", spatial_key="spatial", fov_key="fov")
|
|
|
153
153
|
**Orientation flips.** truecell/Seurat store features × cells; AnnData stores
|
|
154
154
|
cells × features. The conversion handles it — don't transpose by hand on top.
|
|
155
155
|
|
|
156
|
+
**Space travels in Scanpy's layout.** `obsm["spatial"]` holds one (x, y) per cell,
|
|
157
|
+
from the first image that places it (NaN if none does); `obs["fov"]` names that image;
|
|
158
|
+
`uns["spatial"][name]` holds a `VisiumV2`'s tissue image and scale factors. That is
|
|
159
|
+
what Squidpy reads, and `from_anndata` rebuilds the same images from it, including a
|
|
160
|
+
file `scanpy.read_visium` wrote. Cell polygons and molecules have nowhere to go in
|
|
161
|
+
AnnData and stay behind; a segmentation-only image is written at its centroids.
|
|
162
|
+
Pass `assay=` on the way back — `from_anndata` does not read it from `uns`.
|
|
163
|
+
|
|
156
164
|
## Subsetting
|
|
157
165
|
|
|
158
166
|
```python
|
|
@@ -165,3 +173,27 @@ sub = obj.subset(features=gene_list) # by feature
|
|
|
165
173
|
rebinding is the bug. QC filtering is normally expressed as a boolean mask over
|
|
166
174
|
`obj.meta_data` turned into a barcode list, since there is no
|
|
167
175
|
`subset(subset = expr)` string-expression form.
|
|
176
|
+
|
|
177
|
+
The result keeps the **object's** cell order, whatever order `cells` arrives in,
|
|
178
|
+
as Seurat's `intersect(colnames(x), cells)` does, so every slot stays aligned.
|
|
179
|
+
Identity levels keep their order, and levels no kept cell carries are dropped
|
|
180
|
+
(`Idents(x, drop = TRUE)`). A barcode the object does not have raises `KeyError`,
|
|
181
|
+
where Seurat drops it silently.
|
|
182
|
+
|
|
183
|
+
## Slimming — `diet_truecell` (Seurat's `DietSeurat`)
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
slim = truecell.diet_truecell(obj, layers="counts", dimreducs="pca")
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Keeps chosen assays / layers / features / reductions / graphs and drops the
|
|
190
|
+
rest. Returns a **new** object and leaves the input alone; the surviving layers
|
|
191
|
+
are *shared*, not copied, so it frees memory rather than doubling it.
|
|
192
|
+
|
|
193
|
+
**`dimreducs` and `graphs` are keep-LISTS.** `diet_truecell(obj)` with no
|
|
194
|
+
arguments deletes **every** reduction and graph — that is Seurat's behaviour,
|
|
195
|
+
not a porting slip. Name what you want kept or you lose your embedding.
|
|
196
|
+
|
|
197
|
+
`layers` takes a name, a list, or a dict for per-assay control
|
|
198
|
+
(`{"RNA": "counts", "ADT": ["counts", "data"]}`). Removing the current default
|
|
199
|
+
assay raises rather than silently re-pointing it.
|