nico_tutorial

A package that performs cell type annotations on single cell resolution of spatial transcriptomics data, find the niche interactions and statistically enriched covariation of gene programs between interacting cell types from the neighborhood.

https://github.com/ankitbioinfo/nico_tutorial

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: nature.com, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.9%) to scientific vocabulary

Keywords

merfish niche-covariation niche-modelling nico scrna-seq scrna-seq-analysis scrna-seq-data scrnaseq seqfish spatial-transcriptomics
Last synced: 6 months ago · JSON representation ·

Repository

A package that performs cell type annotations on single cell resolution of spatial transcriptomics data, find the niche interactions and statistically enriched covariation of gene programs between interacting cell types from the neighborhood.

Basic Info
Statistics
  • Stars: 10
  • Watchers: 1
  • Forks: 3
  • Open Issues: 7
  • Releases: 1
Topics
merfish niche-covariation niche-modelling nico scrna-seq scrna-seq-analysis scrna-seq-data scrnaseq seqfish spatial-transcriptomics
Created about 2 years ago · Last pushed 7 months ago
Metadata Files
Readme License Citation

README.md

README

NiCo Package DOI

Table of Contents

Overview

For a better presentation of this page, you can also visit Gitbook.

We have developed the NiCo (Niche Covariation) package for the integration of single-cell resolution spatial transcriptomics and scRNA-seq data. NiCo allows you to:

(1) Perform cell type annotations in the spatial modality by label transfer.\ (2) Predict niche cell type interactions within local niche neighborhoods.\ (3) Infer cell state covariation and the underlying molecular crosstalk in the niche.

NiCo infers factors capturing cell state variability in both modalities and identifies genes correlated to these latent factors to predict ligand-receptor interactions and factor-associated pathways.

Tutorial

NiCo can be used on data generated by any spatial transcriptomics method, but it is mainly designed for single-cell resolution spatial technologies such as MERFISH, seqFISH, Xenium etc.

We are providing a first tutorial on running the NiCo pipeline for the data integration of single-cell RNA-sequencing (reference) and single-cell resolution spatial transcriptomics data (query).

The second NiCo tutorial showcases an application to low-resoution genome-wide sequencing-based spatial transcriptomics data where integration with single-cell RNA-sequencing data is not required.

Please use the tutorial link below and keep all the files (NiCoLRdb.txt and *.ipynb) and folders (inputRef, inputQuery; after unzipping) in the same path to complete the tutorial.

Tutorial 1: High-resolution spatial technologies (seqFISH, MERFISH or MERSCOPE, and Xenium)

  • Part A: Data Preparation Extract all zip files and run the Juypter notebook Start_Data_prep.ipynb to create the data files for NiCo analysis.
  • Part B: Running NiCo on selected cell types After data preparation and generating normalised data files, run the Jupyter notebook nico_analysis_highres_image_tech.ipynb to perform the core steps of NiCo.\ This tutorial explains all steps of the NiCo pipeline, including annotation of cell types in the spatial modality by label transfer from the scRNA-seq data, prediction of significant cell type niche interactions, and derivation of cell state covariation within the local niche.\ By default, the figures generated are saved both in the respective directory and inside the notebook.\ Please refer to the documentation for details on functions and parameters.\ The data source is provided in the manuscript.
  • Part B: Running NiCo on all cell types If users want to perform NiCo analysis on the full data without specifying any cell type, refer to the script. nico_analysis_highres_image_tech.py. The output log can be seen here. Due to large number of images, a Jupyter notebook might not display them properly. However, leaving the choose_celltypes and choose_factors_id lists blank will enable the full analysis.

Tutorial 2: Sequencing-based spatial technologies (Slide-seqV2)

Run NiCo on cerebellum data from Slide-seqV2 technology [data from Cable, D. M. et al. Nature methods 19, 1076–1087 (2022)].

  • Download the data from this link and place the data in the following path to complete the tutorial: nico_cerebellum/cerebellum.h5ad
  • The NiCo niche detection and covariation analysis tasks can be run via following the jupyter notebook nico_analysis_lowres_seq_tech.ipynb

Notes on Data Preparation

Sometimes, computing Pearson residuals in the shared gene space for scRNA-seq data can result in NaN values. In such cases, it's recommended to apply filter_cells after aligning to the shared gene space to remove problematic cells. This helps ensure that downstream analyses are not affected by cells with zero counts or low-quality measurements.

General ad_seq_common=ad_seq_ori[:,index_sc].copy() ad_seq_common.raw=ad_seq_common.copy() sc.experimental.pp.normalize_pearson_residuals(ad_seq_common,inplace=True) ad_seq_common.write_h5ad(scdatapath+'sct_singleCell.h5ad')

In special case when NaN value arises. ad_seq_common=ad_seq_ori[:,index_sc].copy() sc.pp.filter_cells(ad_seq_common, min_counts=5) ad_seq_common.raw=ad_seq_common.copy() sc.experimental.pp.normalize_pearson_residuals(ad_seq_common,inplace=True) ad_seq_common.write_h5ad(scdatapath+'sct_singleCell.h5ad')

Prerequisites

Please follow the instructions provided in the nico-sc-sp pip repository for set up and installation.

Installation

Tested NiCo 1.5.0 in following configuration MacOS Sequoia with Apple M4 Max Chip MacOS Sonoma with Intel graphics Ubuntu OS 24.10 Oracular

For detailed instruction, visit the nico-sc-sp pip repository

console conda create -n nicoUser python=3.11 conda activate nicoUser pip install nico-sc-sp

Sometimes, the pygraphviz package cannot be installed via pip, or during the cell type interaction part it returns an error that "neato" is not found in the path, so an alternative installation via conda is recommended. Please follow the installation of pygraphviz here

console conda create -y -n nicoUser python=3.11 conda activate nicoUser conda install -c conda-forge pygraphviz pip install nico-sc-sp pip install jupyterlab

🔄 Changes in version 1.5.0 (from 1.4.0)

  • MacBook Silicon (Apple M-series) support:
    The package has now been tested and confirmed to work on Apple Silicon machines.

  • 🎨 Centered colormap at 0 in plot_significant_regression_covariations_as_circleplot
    for better interpretability of regression results.
    Thanks to Andy Shing Fung Chan for the modification!

Notes and Warnings

Error in any other system

Some error was reported in few cases (not every case can be tested) during the installation of pygraphviz package along with NiCo. So that complete installation was not possible. note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pygraphviz Running setup.py clean for pygraphviz Failed to build pygraphviz ERROR: Failed to build installable wheels for some pyproject.toml based projects (pygraphviz)

In such cases please download the scripts and utils from here and placed in your current directory. And from python prompt load the module in following way
import Annotations as sann import Interactions as sint import Covariations as scov

Function Parameters

To check the usage of any function you can execute the command as in the example:.
[<moduleName>.<functionName>.__doc__] print(scov.save_LR_interactions_in_excelsheet_and_regression_summary_in_textfile_for_interacting_cell_types.__doc__)

Font

If at any step returns the warning findfont: Font family 'Helvetica' not found please initialize the matplotlibrc file to use a different font:

import matplotlib.pyplot as plt plt.rcParams['font.family'] = 'sans-serif' plt.rcParams['font.sans-serif'] = ['Tahoma', 'DejaVu Sans','Lucida Grande', 'Verdana']

Vizgen MERSCOPE data

If you are working with Vizgen MERSCOPE spatial data, please process the output with the "process_vizgenData.py" script to convert Vizgen data into gene_by_cell.csv and tissue_positions_list.csv files.

Cellbarcode name

If you encounter any issues while running, please ensure that the cell barcode name is composed of characters rather than integer numbers. When pandas reads numeric values, it will read as int64 instead of objects which creates datatype confusion in other parts of the code. Therefore, please convert your cell barcode numbers to strings if they are purely numeric.

Talk

I presented a talk on the NiCo algorithm at BPPB seminar. If you're curious to learn more in detail, you can check it out here!. Talk about NiCo

Documentation

For detailed documentation of NiCo modules and their usage, visit NiCo documentation.

Citing NiCo

If you use NiCo in your research, please cite it as follows:

  • Ankit Agrawal, Stefan Thomann, Sukanya Basu, Dominic Grün. NiCo Identifies Extrinsic Drivers of Cell State Modulation by Niche Covariation Analysis. Nature Communications, 2024 Article link

Contact

contact: If you face any problem during the tutorial or have any questions, please email me (ankitplusplus at gmail.com) or raise an issue on GitHub.

License

MIT License

Owner

  • Name: @nkit
  • Login: ankitbioinfo
  • Kind: user
  • Location: Würzburg Germany

I am postdoctoral researcher at Lehrstuhl für Computational Biology of Spatial Biomedical Systems.

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Agrawal"
  given-names: "Ankit"
  orcid: "https://orcid.org/0009-0006-1700-2397"
- family-names: "Thomann"
  given-names: "Stefan"
  orcid: ""
- family-names: "Basu"
  given-names: "Sukanya"
  orcid: ""
- family-names: "Dominic"
  given-names: "Grün"
  orcid: ""
title: "NiCo Identifies Extrinsic Drivers of Cell State Modulation by Niche Covariation Analysis"
version: v1.3.0
doi: 10.5281/zenodo.13902981
date-released: 2024-10-08
url: "https://doi.org/10.5281/zenodo.13902981"

GitHub Events

Total
  • Issues event: 9
  • Watch event: 7
  • Issue comment event: 13
  • Push event: 23
  • Fork event: 2
Last Year
  • Issues event: 9
  • Watch event: 7
  • Issue comment event: 13
  • Push event: 23
  • Fork event: 2

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 23
  • Total Committers: 1
  • Avg Commits per committer: 23.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 23
  • Committers: 1
  • Avg Commits per committer: 23.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
@nkit 3****o 23

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 4
  • Total pull requests: 0
  • Average time to close issues: about 10 hours
  • Average time to close pull requests: N/A
  • Total issue authors: 3
  • Total pull request authors: 0
  • Average comments per issue: 0.25
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 0
  • Average time to close issues: about 10 hours
  • Average time to close pull requests: N/A
  • Issue authors: 3
  • Pull request authors: 0
  • Average comments per issue: 0.25
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • kewinds (2)
  • annachernysheva179 (1)
  • reinertanalytics (1)
  • xwangda (1)
  • bmateosa (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels