Skip to content

This repo is provided for the reproduction of figures and analyses found in the manuscript Lee et al. 2024, bioRxiv. It should be useful for both reviewers and interested researchers.

Notifications You must be signed in to change notification settings

EricKenjiLee/PhysMAP_Manuscript

Repository files navigation

PhysMAP

R code for multi-modal analysis to delineate cell types using electrophysiology.

⚠️WARNING⚠️: If you are a reviewer of this manuscript, please do not star or fork this repo! Doing so breaks reviewer anonymity. If you have problems running the code, please leave your questions on the review.

Note: While this code reproduces figures in the associated manuscript, system (operating system) differences will result in plots that differ in appearance but this does not materially affect any results (see manuscript Supp. Fig. 2).

Generating Manuscript Figures

Regenerating the figures/results found in the manuscript Lee et al. 2024 can be done by simply running the scripts described below for each session. The only requirement is to first install Seurat v4 (and specifically v4) as newer versions of Seurat are incompatible with this analysis. To do this, the first optional step should be followed. Analysis for each dataset should be replicated by running each script in the order presented. Each analysis can be run independently of each other.

(Optional) Installation of Seurat v4 (Hao and Hao et al. 2021)

PhysMAP_Manuscript/juxtacellular (Mouse S1 Juxtacellular Dataset from Yu et al. 2019)

  1. processJianing.r: This code produces all the analyses on the juxtacellular dataset in the manuscript with the exception of the classifier. The produced plots are as follows:
    • A MARI (modified adjusted Rand index) plot over various clustering resolution parameter values.
    • A UMAP plot of each of the three modalities used (waveform shape, ISI distribution, and PSTH) and also concatenated dataset.
    • The visualized PhysMAP WNN colored by cell type plus depth, cell type, and by a sample clustering.
    • The previous PhysMAP visualizations now with marker sized according to the univariate waveform features of spike width and peak-to-trough ratio.
    • A scatterplot of log(spike width) and log(peak-to-trough) ratio with histograms on the marginals.
    • PhysMAP with each unit now as a pie chart showing the proportion each modality contributes to its WNN connections.
    • The weight that each modality contributes to each unit, now as a histogram
  2. classifyData.r: A classifier is trained on the dimensionality reduced WNN and compared against each modality individually and waveform features (spike width and peak-to-trough ratio).
  3. classifyRaw.r: A classifier is now trained on the full dataset (all modalities concatenated) to identify several cell types without application of PhysMAP.

PhysMAP_Manuscript/InvivoA1 (Mouse A1 Probe Extracellular Dataset from Lakunina et al. 2020)

  1. processSantiago.r: This code computes PhysMAP and also performs classification analysis on the dataset. It produces the following plots,
    • A PhysMAP visualization with each opto-tagged cell type colored
    • A sample unsupervised clustering of PhysMAP's WNN
    • Side-by-side plots of PhysMAP, UMAP applied to waveform shape, and UMAP applied to ISI distribution. Marker size was determined by the level of "modulation" defined as the ratio of firing rates under stimulation and at baseline.
    • A classifier trained to identify PV+, SOM+, and undefined (untagged) cells from PhysMAP's dimensionality reduced WNN.

PhysMAP_Manuscript/CellExplorerv2 (Mouse Visual Cortex and Hippocampus Datasets from Petersen et al. 2021)

  1. processCellExp.r: This script takes data from visual cortex and hippocampus provided as part of the CellExplorer dataset and analyzes them with PhysMAP. In particular, waveform shapes, ISI distributions, autocorrelograms, and "features" are used to compute the weighted representation. The features modality consist of the twelve measures mentioned in the methods section titled "Extracellular Mouse Visual Cortex and Hippocampus Dataset (CellExplorer). Further descriptions of these features can be found at https://cellexplorer.org/datastructure/standard-cell-metrics/. A series of plots are created:
    • a UMAP of each of four modalities side-by-side
    • a sample Louvain clustering of the WNN
    • The WNN colored by each cell type
    • The WNN colored according to its source at either the Allen Institute for Brain Science or the Buzsaki lab
    • The WNN colored according to the brain area it was collected from
    • The WNN colored according to brain area plus cell type
  2. classifyCellExp.r: A cross-validated classifier is trained to identify one of six cell types (pyramidal, PV+, SST+, axo-axonic PV+, excitatory, and VIP+). This classifier is trained on the dimensionality reduced WNN representation.

PhysMAP_Manuscript/lookupTable (Cell Type Classifier built on data from Petersen et al. 2021)

  1. mapReferenceAllen_Kenji.r: This applies PhysMAP to the data from CellExplorer. It produces the following plots,
    • Side-by-side UMAP projections of waveform shape, ISI distribution, and the twelve univariate features
    • A sample clustering of PhysMAP's WNN graph
    • The PhysMAP projection colored by the cell type labels obtained from CellExplorer
  2. lookupTable.r: This script conducts the anchor alignment between the reference and query datasets. Note that only PV+, pyramidal, SST+, and VIP+ cells were uniquely considered because axo-axonic cells are a PV+ subtype, juxtacellular cells are excitatory cells recorded with a juxtacellular electrode, and VGAT+ cells are a pan-inhibitory type. This code produces the following plot and also outputs the true and predicted labels for each unit.
    • The reference dataset visualized with PhysMAP (left) and the query dataset of held-out data projected onto the reference data (right).

Session Info

The following dependencies are not a strict requirement but are those in which we know are compatible and are a snapshot of a working set. This project is not compatible with Seurat v5 as there were breaking changes introduced into our usage of anchor alignment.

R version 4.2.2 (2022-10-31) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Ventura 13.5.1

Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale: en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: stats graphics grDevices utils datasets methods base

other attached packages: aricode_1.0.3 R.matlab_3.7.0 cowplot_1.1.3 SeuratObject_5.0.1 Seurat_4.1.0 here_1.0.1 reshape2_1.4.4 nnet_7.3-18 caret_6.0-94 lattice_0.20-45 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.0 tidyverse_2.0.0

About

This repo is provided for the reproduction of figures and analyses found in the manuscript Lee et al. 2024, bioRxiv. It should be useful for both reviewers and interested researchers.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published