Comments (1)
Hi @debbie28!
This is a great question! I will divide it in two parts:
-
'I have a cisTopic analysis in R, can I still use it for SCENIC+?'
Yes, you can! There is no need to repeat the topic modelling in Python :). For this, you will need to do the following in R first: ``` # Export data to python library(arrow) path <- OUTDIR cisTopic_obj <- readRDS(PATH_TO_YOUR_CISTOPICOBJECT) modelMat <- modelMatSelection(cisTopic_obj, 'cell', 'Probability') modelMat <- as.data.frame(modelMat) write_feather(modelMat, sink=paste0(path, 'model_to_pycisTopic/cell_topic.feather')) modelMat <- modelMatSelection(cisTopic_obj, 'region', 'Probability', all.regions=TRUE) modelMat <- as.data.frame(modelMat) write_feather(modelMat, sink=paste0(path, 'model_to_pycisTopic/topic_region.feather')) # You can also save the count.matrix ct <- [email protected] ct <- as.data.frame(ct) write_feather(ct, sink=paste0(path, 'model_to_pycisTopic/count_matrix.feather')) ``` And then in Python: ``` import pycisTopic ## 1. Initialize cisTopic object from pycisTopic.cistopic_class import * # Load count matrix matrix_path=PATH_TO_FRAGMENTS_MATRIX fragment_matrix = pd.read_feather(matrix_path) cisTopic_obj = create_cistopic_object(fragment_matrix) # Also add the cell annotation, cell_data should be a pandas df with cells as rows (cell names as index) and variables as columns cisTopic_obj.add_cell_data(cell_data) # 2. Add model from pycisTopic.utils import * model = load_cisTopic_model(PATH_TO_THE_FOLDER_WHERE_YOU_SAVED_DATA_FROM_R) cistopic_obj.add_LDA_model(model) # 3. Get imputed accessibility matrix from pycisTopic.diff_features import * imputed_acc_obj = impute_accessibility(cistopic_obj, selected_cells=None, selected_regions=None, scale_factor=10**6) # 4. DARs normalized_imputed_acc_obj = normalize_scores(imputed_acc_obj, scale_factor=10**4) variable_regions = find_highly_variable_features(normalized_imputed_acc_obj, min_disp = 0.05, min_mean = 0.0125, max_mean = 3, max_disp = np.inf, n_bins=20, n_top_features=None, plot=True) markers_dict= find_diff_features(cistopic_obj, imputed_acc_obj, variable='cell_type', # Here put the column of cell_data that you want to have DARs for var_features=variable_regions, contrasts=None, adjpval_thr=0.05, log2fc_thr=np.log2(1.5), n_cpu=5) # You can continue with pycistarget. ``` Feel free to change the function if you do not want to work in feather format. ``` def load_cisTopic_model(path_to_cisTopic_model_matrices): metrics = None coherence = None marg_topic = None topic_ass = None cell_topic = pd.read_feather(path_to_cisTopic_model_matrices + "cell_topic.feather") cell_topic.index = ["Topic" + str(x) for x in range(1, cell_topic.shape[0] + 1)] topic_region = pd.read_feather( path_to_cisTopic_model_matrices + "topic_region.feather" ) topic_region.index = ["Topic" + str(x) for x in range(1, topic_region.shape[0] + 1)] topic_region = topic_region.T parameters = None model = cisTopicLDAModel( metrics, coherence, marg_topic, topic_ass, cell_topic, topic_region, parameters ) return model ```
-
'I have an analysis with another tool (e.g. Signac/ArchR), can I still use it for SCENIC+?'
Here you have two options:
- Start from the count matrix: If you have performed QC steps and generated you fragment count matrix with another tool, you can directly start with the creation of the cisTopic object. In this tutorial you have an example on how to do this.
- You want to skip the topic modelling altogether: I would not recommend this option because we have not tested it, but technically it is possible. You would need to get 1) a denoised fragment matrix and 2) region sets. The region sets will be used as input for cisTarget. The region sets could be Differentially Accessible Regions (DARs); however we do recommend to use topics as well as they can capture regions with accessibility patterns without the need of specifying contrasts. If only using DARs you will have to make sure to make the right contrats (for example, all cell types versus the rest; higher cell type groups versus rest, etc). For example, in the cortex data set the topics reveal a topic of regions shared across all neurons; this pattern would be lost if you only do contrasts per cell type and not higher groups. In conclusion, it is possible to plug it in code-wise; but we can't assure results will be as good as the workflow we propose.
I will add these responses in a FAQs tab in the readthedocs page as I find them very relevant, thanks for the heads up!
C
from scenicplus.
Related Issues (20)
- Failing to integrate scATAC + scRNA cells (non multiome data). Error in rule prepare_GEX_ACC_non_multiome: HOT 1
- how to prepare motif2tf file for `path_to_motif_annotations` in plant HOT 2
- Data base HOT 2
- pip installation issue HOT 3
- 'PyRanges object has no attribute', 'Count' HOT 1
- error runing scenic+ HOT 1
- Error in tf_to_gene HOT 6
- Missing files for `scenicplus init_snakemake --out_dir` HOT 2
- pyscenic dependency HOT 1
- SCENIC+ prepare_menr error: TypeError unbound method set.union() needs an argument HOT 4
- "enable_string_cache()" in export_pseudobulk using tutorial data HOT 1
- TypeError: descriptor '__call__' for 'type' objects doesn't apply to a 'property' object HOT 3
- Count matrix to cistopic link broken + scalability to large datasets question HOT 4
- How can I convert a SCENIC+ object to a loom file?
- `ValueError: No objects to concatenate` during `motif_enrichment_dem` Execution HOT 1
- QC files are not formed HOT 2
- Region set, scores.feather and NameError: name 'run_cgs_models_mallet HOT 3
- Input annotated 10x Multiome Seurat object into SCENIC+ HOT 1
- how much resource needed? Multiome datasets with 270k cells HOT 1
- SCENIC+ crashed in tf_to_gene step HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scenicplus.