Berg et al. (2020): human supragranular glutamatergic neurons, from dandiset 000023¶
- Paper. Berg, Sorensen, Ting, Miller et al. (2020), "Human cortical expansion involves diversification and specialization of supragranular intratelencephalic-projecting neurons", bioRxiv, doi:10.1101/2020.03.31.018820, version 1.
- Dataset. DANDI:000023, "Patch-seq recordings from human cortex (June 2020)", version 0.210914.1900 (doi:10.48324/dandi.000023/0.210914.1900). The paper cites no version of the dandiset and the claims file gives none. This is the only published version, so it is pinned; the draft holds the same files (checked below).
- Claims file.
claims/000023/10.1101-2020.03.31.018820.yaml, written from the bioRxiv preprint, version 1 (main text, Methods, figure and Extended Data legends), and from the paper's code, AllenInstitute/patchseq_human_L23 at commit 3daf9f0. - Outside inputs. The dandiset holds only the human electrophysiology, with no t-type, depth or
specimen ID. Labels (t-type, normalized L2/3 depth, region), donor pathology scores, the mouse
features, the morphological features, the gene-depth table and the NeuN section ROIs come from
the code repository at commit 3daf9f0. Questions to the readers, and their answers, are in
questions/000023.yaml; the claims they bear on were updated in the claims file, and this notebook follows the updated criteria.
| Claim | Data | Tested |
|---|---|---|
| features-and-labels-link | with labels | yes, readings M1 and M2 (the claims that need labels use M2) |
| cohort-cells, cohort-donors, cohort-type-counts | with labels | yes |
| fig3d-depth-by-type | with labels | yes |
| fig4e-human-ephys-anova, fig4-glp2r-sag | with labels | yes |
| fig4e-mouse-ephys-anova, edtable1-species-ephys, edfig6-classifier-mouse-ephys | with inputs | yes (mouse features from the code) |
| edfig6-classifier-human-ephys, fig5c-frem3-ephys-depth | with labels | yes |
| fig6-deep-ephys-anova, fig6c-carm1p1-upstroke-rin, fig6c-col22a1-rin-fi-sag | with labels | yes |
| fig2ef-pathology-ephys | with inputs | yes |
| fig2d-pathology-scores, edfig1-marker-correlation | elsewhere (code) | yes |
| fig4f-morph-anova, fig5b-frem3-morph-depth, fig6-deep-morph-anova | elsewhere (code) | yes |
| fig5d-frem3-gene-depth | elsewhere (code) | computed; blocked (the table is the revision's) |
| fig1a-thickness, fig1b-density, fig1c-soma-area, fig1c-soma-variation | elsewhere (code) | yes |
| fig6a-deep-dendrites, edfig6-classifier-morphoelectric | elsewhere (code) | yes (methods from the answers); fig6a blocked, its readings differ |
| fig1f-frem3-heterogeneity, fig1g-deep-types-de-genes, fig3a-platform-correlation, fig6e-deep-de-genes, fig6f-smi32 | elsewhere | blocked (no pinned or public data) |
The features are computed after the sweep QC of the Methods, as the link criterion asks; IPFX's own sweep QC, which leaves out the Methods' bias current and bridge balance limits, is run as a variant, and a section near the end shows how every electrophysiology outcome changes with the QC and the cell set.
The notebook took about 21 minutes in its last run (printed at the end): about 7 to read and analyse the 318 files with IPFX, about 5 and 4 for the two electrophysiology classifiers of 1000 splits each, and about 3.5 for the morpho-electric classifiers (250 splits each).
import os
for _v in ("OMP_NUM_THREADS", "OPENBLAS_NUM_THREADS", "MKL_NUM_THREADS"):
os.environ.setdefault(_v, "1")
import time
import warnings
import zlib
from itertools import combinations
import h5py
import io
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import stats
import patchseq_l23 as P
warnings.filterwarnings("ignore")
pd.set_option("display.width", 220)
pd.set_option("display.max_columns", 40)
pd.set_option("display.max_rows", 300)
T0 = time.time()
def rng_for(claim):
"""Each claim's own random generator, seeded from its id."""
return np.random.default_rng(zlib.crc32(claim.encode()))
F = P.FEATURES
UNITS = dict(adapt_mean="ratio", avg_rate_hero="Hz", downstroke_long_square="mV/ms",
fast_trough_v_long_square_rel="mV", fi_fit_slope="Hz/pA", first_isi_hero_inv="Hz",
input_resistance="MOhm", latency_rheo="s", peak_v_long_square_rel="mV", rheobase_i="pA",
sag="ratio", tau="s", threshold_v_long_square="mV", trough_v_long_square_rel="mV",
upstroke_downstroke_ratio_long_square="ratio", upstroke_long_square="mV/ms", v_baseline="mV",
width_long_square="s")
The dataset, its versions and the paper's code tables¶
info = P.version_info()
versions = P._get_json(f"{P.API}/dandisets/{P.DANDISET}/versions/")["results"]
print(pd.DataFrame([dict(version=v["version"], status=v["status"], assets=v["asset_count"],
size_gb=round(v["size"] / 1e9, 2), modified=v["modified"][:10]) for v in versions]))
summ = info["assetsSummary"]
print("\n", info["name"], "|", info["description"])
print("related:", [(r["relation"], r["url"]) for r in info["relatedResource"]])
print("archive summary: subjects", summ["numberOfSubjects"], "| files", summ["numberOfFiles"],
"| species", [s["name"] for s in summ["species"]], "| variables", summ["variableMeasured"],
"| technique", [t["name"] for t in summ["measurementTechnique"]], "| approach", summ.get("approach"))
assets = P.list_assets()
draft = P.list_assets("draft")
print(f"\npinned version {P.VERSION}: {len(assets)} assets, {assets.subject_id.nunique()} subjects, "
f"{assets['size'].sum() / 1e9:.2f} GB")
print("draft holds the same files (same blobs and paths):",
set(zip(draft.path, draft.url)) == set(zip(assets.path, assets.url)))
version status assets size_gb modified
0 draft Valid 318 12.4 2023-06-20
1 0.210914.1900 Valid 318 12.4 2021-09-14
Patch-seq recordings from human cortex (June 2020) | Whole-cell Patch-seq recordings from neurons of the human neocortex from the Allen Institute for Brain Science, released in June 2020.
related: [('dcite:IsSupplementTo', 'https://www.biorxiv.org/content/10.1101/2020.03.31.018820v1')]
archive summary: subjects 56 | files 318 | species ['Human'] | variables ['ProcessingModule'] | technique ['analytical technique'] | approach []
pinned version 0.210914.1900: 318 assets, 56 subjects, 12.40 GB draft holds the same files (same blobs and paths): True
cell_tab = P.code_table("human_IVSCC_excitatory_L23_consolidated_0131.csv")
ephys_tab = P.code_table("human_mouse_ephys_all_0127.csv")
mouse_tab = P.code_table("mouse_IVSCC_excitatory_L23_consolidated_0129.csv")
path_tab = P.code_table("pathology_scoring.csv")
morph_h = P.code_table("All_L23_Lockdown_all_raw_features.csv")
morph_m = P.code_table("All_Mouse_Cells_Lockdown_All_raw_features.csv")
morph_names = P.code_table("morpho_feature_names.csv")
genes_depth = P.code_table("frem_genes_depth.csv")
donor_tab = P.code_table("hIVSCC Manuscript Donor Table - Extended Data Table 1.csv")
for name, t in [("human cell table", cell_tab), ("feature table (human and mouse)", ephys_tab),
("mouse cell table", mouse_tab), ("pathology scores", path_tab),
("human morphology", morph_h), ("mouse morphology", morph_m), ("gene-depth results", genes_depth),
("donor table", donor_tab)]:
print(f"{name}: {t.shape[0]} rows, {t.shape[1]} columns")
print("\nhuman cell table columns:", list(cell_tab.columns))
human cell table: 385 rows, 27 columns feature table (human and mouse): 447 rows, 19 columns mouse cell table: 133 rows, 18 columns pathology scores: 90 rows, 9 columns human morphology: 109 rows, 61 columns mouse morphology: 60 rows, 61 columns gene-depth results: 33245 rows, 7 columns donor table: 117 rows, 10 columns human cell table columns: ['SpecimenID', 'sample_id', 'batch', 'donor', 'collaborator', 'gender', 'medical_conditions', 'region', 'hemisphere', 'age', 'ethnicity', 'depth_from_pia_microns', 'total_cortical_depth', 'L23_cell_depth', 'L23_total_thickness', 'L23_depth_normalized', 'flag', 'isTCX', 'postPatch', 'rna_amplification_call', 'marker_sum_norm', 'quality_score', 'contam_sum', 'contaminationType', 'SeuratMapping', 'SeuratMappingScore', 'Is_deep_FREM3']
What one file holds¶
Every group and dataset of one file, with the per-sweep series collapsed to one line per kind.
raw0 = P.read_bytes(assets.url[0])
f0 = h5py.File(io.BytesIO(raw0), "r")
seen = {}
def _walk(name, obj):
parts = name.split("/")
key = name
for n_prefix, prefix in ((1, "acquisition"), (2, "stimulus/presentation"), (2, "processing/spikes")):
if name.startswith(prefix + "/") and len(parts) > n_prefix:
key = "/".join(parts[:n_prefix] + ["<sweep>"] + parts[n_prefix + 1:])
if key not in seen:
seen[key] = (type(obj).__name__, getattr(obj, "shape", ""), str(getattr(obj, "dtype", "")))
f0.visititems(_walk)
for k, v in seen.items():
print(k, *v)
print("\nsweep series attributes:", dict(f0["acquisition"][list(f0["acquisition"])[10]].attrs).keys())
print("session_description:", f0["session_description"][()], "| filtering:", f0["general/intracellular_ephys/filtering"][()])
f0.close()
acquisition Group acquisition/<sweep> Group acquisition/<sweep>/capacitance_fast Dataset (1,) float32 acquisition/<sweep>/capacitance_slow Dataset (1,) float32 acquisition/<sweep>/data Dataset (12500,) float32 acquisition/<sweep>/gain Dataset (1,) float32 acquisition/<sweep>/starting_time Dataset (1,) float64 acquisition/<sweep>/bridge_balance Dataset (1,) float32 acquisition/<sweep>/capacitance_compensation Dataset (1,) float32 acquisition/<sweep>/bias_current Dataset (1,) float32 analysis Group file_create_date Dataset (3,) object general Group general/data_collection Dataset (1,) object general/devices Group general/devices/device_ITC18USB_Dev_0 Group general/generated_by Dataset (5, 2) object general/institution Dataset () object general/intracellular_ephys Group general/intracellular_ephys/electrode_0 Group general/intracellular_ephys/electrode_0/description Dataset (1,) object general/intracellular_ephys/filtering Dataset (1,) object general/intracellular_ephys/sweep_table Group general/intracellular_ephys/sweep_table/id Dataset (142,) int32 general/intracellular_ephys/sweep_table/series Dataset (142,) object general/intracellular_ephys/sweep_table/series_index Dataset (142,) int32 general/intracellular_ephys/sweep_table/sweep_number Dataset (142,) uint32 general/labnotebook Group general/labnotebook/ITC18USB_Dev_0 Group general/labnotebook/ITC18USB_Dev_0/numericalKeys Dataset (3, 128) object general/labnotebook/ITC18USB_Dev_0/numericalValues Dataset (1024, 128, 9) float64 general/labnotebook/ITC18USB_Dev_0/textualKeys Dataset (3, 22) object general/labnotebook/ITC18USB_Dev_0/textualValues Dataset (256, 22, 9) object general/session_id Dataset () object general/source_script Dataset (1,) object general/stimsets Group general/stimsets/C1LSCOARSE150216_DA_0_SegWvType Dataset (102,) float32 general/stimsets/C1LSCOARSE150216_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/C1LSCOARSE150216_DA_0_WPT Dataset (51, 100, 9) object general/stimsets/C1RP25PR1S141203_DA_0_SegWvType Dataset (102,) float32 general/stimsets/C1RP25PR1S141203_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/C1RP25PR1S141203_DA_0_WPT Dataset (51, 100, 9) object general/stimsets/C1SSCOARSE150112_DA_0_SegWvType Dataset (102,) float32 general/stimsets/C1SSCOARSE150112_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/C1SSCOARSE150112_DA_0_WPT Dataset (51, 100, 9) object general/stimsets/C1SSFINEST150112_DA_0_SegWvType Dataset (102,) float32 general/stimsets/C1SSFINEST150112_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/C1SSFINEST150112_DA_0_WPT Dataset (51, 100, 9) object general/stimsets/EXTPBREAKN141203_DA_0_SegWvType Dataset (102,) float32 general/stimsets/EXTPBREAKN141203_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/EXTPBREAKN141203_DA_0_WPT Dataset (51, 100, 9) object general/stimsets/EXTPCllATT141203_DA_0_SegWvType Dataset (102,) float32 general/stimsets/EXTPCllATT141203_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/EXTPCllATT141203_DA_0_WPT Dataset (51, 100, 9) object general/stimsets/EXTPEXPEND141203_DA_0_SegWvType Dataset (102,) float32 general/stimsets/EXTPEXPEND141203_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/EXTPEXPEND141203_DA_0_WPT Dataset (51, 100, 9) object general/stimsets/EXTPGGAEND141203_DA_0_SegWvType Dataset (102,) float32 general/stimsets/EXTPGGAEND141203_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/EXTPGGAEND141203_DA_0_WPT Dataset (51, 100, 9) object general/stimsets/EXTPINBATH141203_DA_0_SegWvType Dataset (102,) float32 general/stimsets/EXTPINBATH141203_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/EXTPINBATH141203_DA_0_WPT Dataset (51, 100, 9) object general/stimsets/EXTPSMOKET141203_DA_0_SegWvType Dataset (102,) float32 general/stimsets/EXTPSMOKET141203_DA_0_WP Dataset (31, 100, 8) float32 general/stimsets/EXTPSMOKET141203_DA_0_WPT Dataset (51, 100, 9) object general/subject Group general/subject/age Dataset () object general/subject/description Dataset (1,) object general/subject/genotype Dataset () object general/subject/sex Dataset () object general/subject/species Dataset () object general/subject/subject_id Dataset () object general/testpulse Group general/testpulse/ITC18USB_Dev_0 Group general/testpulse/ITC18USB_Dev_0/TPStorage Dataset (4096, 1, 11) float32 general/user_comment Group general/user_comment/ITC18USB_Dev_0 Group general/user_comment/ITC18USB_Dev_0/userComment Dataset (1,) object identifier Dataset (1,) object processing Group processing/spikes Group processing/spikes/<sweep> Group processing/spikes/<sweep>/data Dataset (0,) float64 processing/spikes/<sweep>/timestamps Dataset (0,) float64 session_description Dataset (1,) object session_start_time Dataset (1,) object specifications Group specifications/core Group specifications/core/2.2.4 Group specifications/core/2.2.4/namespace Dataset (1,) object specifications/core/2.2.4/nwb.base Dataset (1,) object specifications/core/2.2.4/nwb.behavior Dataset (1,) object specifications/core/2.2.4/nwb.device Dataset (1,) object specifications/core/2.2.4/nwb.ecephys Dataset (1,) object specifications/core/2.2.4/nwb.epoch Dataset (1,) object specifications/core/2.2.4/nwb.file Dataset (1,) object specifications/core/2.2.4/nwb.icephys Dataset (1,) object specifications/core/2.2.4/nwb.image Dataset (1,) object specifications/core/2.2.4/nwb.misc Dataset (1,) object specifications/core/2.2.4/nwb.ogen Dataset (1,) object specifications/core/2.2.4/nwb.ophys Dataset (1,) object specifications/core/2.2.4/nwb.retinotopy Dataset (1,) object specifications/core/2.2.5 Group specifications/core/2.2.5/namespace Dataset () object specifications/core/2.2.5/nwb.base Dataset () object specifications/core/2.2.5/nwb.behavior Dataset () object specifications/core/2.2.5/nwb.device Dataset () object specifications/core/2.2.5/nwb.ecephys Dataset () object specifications/core/2.2.5/nwb.epoch Dataset () object specifications/core/2.2.5/nwb.file Dataset () object specifications/core/2.2.5/nwb.icephys Dataset () object specifications/core/2.2.5/nwb.image Dataset () object specifications/core/2.2.5/nwb.misc Dataset () object specifications/core/2.2.5/nwb.ogen Dataset () object specifications/core/2.2.5/nwb.ophys Dataset () object specifications/core/2.2.5/nwb.retinotopy Dataset () object specifications/hdmf-common Group specifications/hdmf-common/1.1.3 Group specifications/hdmf-common/1.1.3/namespace Dataset (1,) object specifications/hdmf-common/1.1.3/sparse Dataset (1,) object specifications/hdmf-common/1.1.3/table Dataset (1,) object specifications/ndx-mies Group specifications/ndx-mies/0.1.0 Group specifications/ndx-mies/0.1.0/namespace Dataset (1,) object specifications/ndx-mies/0.1.0/ndx-mies.extensions Dataset (1,) object stimulus Group stimulus/presentation Group stimulus/presentation/<sweep> Group stimulus/presentation/<sweep>/data Dataset (12500,) float32 stimulus/presentation/<sweep>/gain Dataset (1,) float32 stimulus/presentation/<sweep>/starting_time Dataset (1,) float64 stimulus/templates Group timestamps_reference_time Dataset (1,) object sweep series attributes: dict_keys(['comments', 'description', 'namespace', 'neurodata_type', 'object_id', 'stimulus_description', 'sweep_number']) session_description: [b'PLACEHOLDER'] | filtering: [b'PLACEHOLDER']
Feature extraction¶
Each file is read whole into memory from the archive (about 70 s for the 12.4 GB at the speeds seen
while preparing) and run through IPFX: sweep QC, then IPFX's long-square analysis on the sweeps that
pass. The sweep QC is the Methods', as the link criterion asks. IPFX 2.1.2's own sweep QC applies only
the noise limits (and a Vm-delta limit); the bias current (0 +/- 100 pA) and bridge balance (below 20
MOhm and 15% of input resistance) limits of the Methods are added here (patchseq_l23.METHODS_SWEEP_QC),
with the input resistance of IPFX's cell QC for the 15% limit. The features under IPFX's sweep QC alone,
which the first round of this attempt used, are kept as a variant. The 18 features are read from IPFX's
output as patchseq_l23.FEATURE_SOURCES says. This took about 7 minutes on four processes in the last run (printed below).
t = time.time()
raw = P.extract_all(assets.url, processes=4)
cells = assets.merge(raw, on="url")
cells["donor"] = cells.cell_name.str.split(".").str[:3].str.join(".")
print(f"extracted {len(cells)} files in {(time.time() - t) / 60:.1f} min; "
f"{cells.error.notna().sum()} gave no features")
print(pd.Series(P.FEATURE_SOURCES, name="read from IPFX as").to_string())
extracted 318 files in 10.0 min; 38 gave no features adapt_mean spiking long squares: mean of adapt avg_rate_hero hero sweep: avg_rate downstroke_long_square rheobase sweep, first spike: downstroke fast_trough_v_long_square_rel rheobase sweep, first spike: fast_trough_v - t... fi_fit_slope long squares: fi_fit_slope first_isi_hero_inv hero sweep: 1 / first_isi input_resistance long squares: input_resistance latency_rheo rheobase sweep: latency peak_v_long_square_rel rheobase sweep, first spike: peak_v - threshold_v rheobase_i long squares: rheobase_i sag long squares: sag tau long squares: tau threshold_v_long_square rheobase sweep, first spike: threshold_v trough_v_long_square_rel rheobase sweep, first spike: trough_v - thresh... upstroke_downstroke_ratio_long_square rheobase sweep, first spike: upstroke_downstro... upstroke_long_square rheobase sweep, first spike: upstroke v_baseline long squares: v_baseline width_long_square rheobase sweep, first spike: width
Data check¶
print("files", len(cells), "| subjects (subject_id)", cells.subject_id.nunique(),
"| donors (from cell names)", cells.donor.nunique(), "| archive summary says",
summ["numberOfSubjects"], "subjects")
print("subject_id in the file equals the path's:", (cells.nwb_subject_id.astype(int) == cells.subject_id).all(),
"| session_id in the file equals the path's:", (cells.nwb_session_id.astype(int) == cells.session_id).all())
print("one donor name per subject_id:", cells.groupby("subject_id").donor.nunique().max() == 1,
"| one subject_id per donor name:", cells.groupby("donor").subject_id.nunique().max() == 1)
per_donor = cells.groupby("donor").size()
print("files per donor: min", per_donor.min(), "median", per_donor.median(), "max", per_donor.max())
print("species", cells.species.value_counts().to_dict(), "| sex of donors",
cells.groupby("donor").sex.first().value_counts().to_dict())
age_y = cells.groupby("donor").age.first().str.extract(r"P([\d.]+)D")[0].astype(float) / 365.25
print(f"donor age (from ISO durations in days): {age_y.min():.1f} to {age_y.max():.1f} years")
# recordings deposited more than once
print("\nduplicate cell names:", cells.cell_name.duplicated().sum(),
"| duplicate session start times:", cells.session_start.duplicated().sum(),
"| files with identical feature vectors:", cells.loc[cells.error.isna(), F].round(9).duplicated(keep=False).sum())
# sweeps, rates, units
sw = pd.DataFrame([dict(path=p, **s) for p, ss in zip(cells.path, cells.sweeps) for s in ss])
from ipfx.stimulus import StimulusOntology
import ipfx.json_utilities as ju
ont = StimulusOntology(ju.read(StimulusOntology.DEFAULT_STIMULUS_ONTOLOGY_FILE))
def ipfx_name(code):
try:
return ont.find_one(code.replace("_DA_0", ""), tag_type="code").tags(tag_type="name")[0][1]
except Exception:
return "not in the ontology"
names = {c: ipfx_name(c) for c in sw.stim.unique()}
sw["ipfx_name"] = sw.stim.map(names)
print("\nsweeps by kind:")
print(sw.groupby("kind").agg(n=("series", "size"), rates_hz=("rate", lambda x: sorted(set(x))),
unit=("unit", lambda x: sorted(set(x))),
conversion=("conversion", lambda x: sorted(f"{v:g}" for v in set(x)))))
print("\ncurrent-clamp stimulus sets (sweeps):")
print(sw[sw.kind == "CurrentClampSeries"].groupby(["ipfx_name", "stim"]).size().to_string())
ls_sw = sw[sw.ipfx_name == "Long Square"]
print(f"\nlong-square sweeps: {len(ls_sw)} in {ls_sw.path.nunique()} files; bridge balance "
f"{ls_sw.bridge_balance.min():.1f} to {ls_sw.bridge_balance.max():.1f} MOhm; bias current "
f"{ls_sw.bias_current.min():.1f} to {ls_sw.bias_current.max():.1f} pA "
f"({ls_sw.bias_current.isna().sum()} sweeps without one)")
durs = sorted(set(d for ds in cells.ls_durations.dropna() for d in ds))
amps = [a for aa in cells.ls_amps.dropna() for a in aa]
print("long-square step durations (s):", durs, "| amplitudes", min(amps), "to", max(amps), "pA")
print("step onset after the experiment epoch start (s):", sorted(cells.step_start.dropna().round(4).unique()))
print("\nlong squares per file: recorded", cells.n_ls_sweeps.describe()[["min", "50%", "max"]].to_dict(),
"| passing sweep QC", cells.n_ls_passed.describe()[["min", "50%", "max"]].to_dict(),
"| total passing", int(cells.n_ls_passed.sum()), "of", int(cells.n_ls_sweeps.sum()))
print("cell QC (computed, not used to drop cells): fail", int(cells.cell_qc_failed.sum()), "of",
int(cells.cell_qc_failed.notna().sum()))
import ipfx
from collections import Counter
G = ["ipfxqc_" + f for f in F] # the features under IPFX's sweep QC alone
print("\nIPFX version", ipfx.__version__)
print("long squares passing IPFX's sweep QC:", int(cells.n_ls_passed_ipfx.sum()), "| passing the Methods' sweep QC "
"(IPFX's plus bias current and bridge balance):", int(cells.n_ls_passed.sum()), "of", int(cells.n_ls_sweeps.sum()))
fail_why = sum((Counter(d) for d in cells.ls_fail_reasons.dropna()), Counter())
print("long-square sweeps failing, by reason (a sweep can have several):", dict(fail_why.most_common()))
bias = pd.Series([b for bb in cells.ls_bias_pa.dropna() for b in bb], dtype=float)
print(f"bias current of long squares, as IPFX reads it: {bias.min():.1f} to {bias.max():.1f} pA, "
f"{int((bias.abs() > 100).sum())} outside +/-100 pA, {int(bias.isna().sum())} with no value (kept)")
print(f"input resistance from IPFX's cell QC (for the 15% bridge balance limit): {cells.rin_cell_qc.min():.0f} to "
f"{cells.rin_cell_qc.max():.0f} MOhm, missing in {int(cells.rin_cell_qc.isna().sum())} files")
print("files with features: Methods' sweep QC", int((cells[F].notna().any(axis=1)).sum()), "| IPFX's sweep QC alone",
int((cells[G].notna().any(axis=1)).sum()), "| files where any feature differs between the two:",
int(((cells[F].to_numpy(float) != cells[G].to_numpy(float)) & ~(cells[F].isna().to_numpy() & cells[G].isna().to_numpy())).any(axis=1).sum()))
print("\nfiles without features, and why (long squares passing the Methods' QC and IPFX's QC alone; IPFX's error):")
cells["features_under_ipfx_qc"] = cells[G].notna().any(axis=1)
print(cells.loc[cells.error.notna(), ["cell_name", "n_ls_passed", "n_ls_passed_ipfx", "features_under_ipfx_qc", "error"]].to_string())
# ranges and units of every feature used
rng_tab = pd.DataFrame({f: dict(unit=UNITS[f], n=int(cells[f].notna().sum()), min=cells[f].min(),
median=cells[f].median(), max=cells[f].max()) for f in F}).T
print("\nfeature ranges (all files):")
print(rng_tab.to_string())
# clock: spikes in the step against the second before it, and IPFX against the file's stored spike times
ok = cells.error.isna()
print(f"\nupward 0 mV crossings in QC-passed long squares: {int(cells.spikes_in_step.sum())} during the "
f"step, {int(cells.spikes_before_step.sum())} in the 1 s before it "
f"({int((cells.spikes_before_step > 0).sum())} files with any before)")
has = cells.stored_dt_ms.notna()
print(f"rheobase sweep: IPFX threshold times against processing/spikes in {int(has.sum())} files; "
f"same spike count in {int((cells.stored_n == cells.ipfx_n)[has].sum())}; largest time difference "
f"{cells.stored_dt_ms.max():.3f} ms (median {cells.stored_dt_ms.median():.3f})")
files 318 | subjects (subject_id) 56 | donors (from cell names) 56 | archive summary says 56 subjects
subject_id in the file equals the path's: True | session_id in the file equals the path's: True
one donor name per subject_id: True | one subject_id per donor name: True
files per donor: min 1 median 3.0 max 25
species {'Homo Sapiens': 318} | sex of donors {'M': 34, 'F': 22}
donor age (from ISO durations in days): 18.0 to 69.0 years
duplicate cell names: 0 | duplicate session start times: 0 | files with identical feature vectors: 0
sweeps by kind:
n rates_hz unit conversion
kind
CurrentClampSeries 20228 [50000.0, 200000.0] [volts] [0.001]
VoltageClampSeries 4608 [3125.0, 25000.0, 50000.0, 200000.0] [amperes] [1e-12]
current-clamp stimulus sets (sweeps):
ipfx_name stim
Long Square C1LSCOARSE150216_DA_0 973
C1LSCOARSEMICRO_DA_0 417
C1LSFINEST150112_DA_0 1027
C1LSFINESTMICRO_DA_0 184
LP_Rheo_DA_0 3
PS_SubThresh_DA_0 5
PS_SupraThresh_DA_0 3
X1PS_SubThresh_DA_0 1008
X3LP_Rheo_DA_0 630
X4PS_SupraThresh_DA_0 553
subthreshold_171_DA_0 636
Noise C1NSD1SHORT17110_DA_0 225
C1NSD2SHORT17110_DA_0 204
C2NSD1SHORT17110_DA_0 108
C2NSD2SHORT17110_DA_0 76
Ramp C1RP25PR1S141203_DA_0 264
Ramp_DA_0 6
X7Ramp_DA_0 610
Search LP_Search_DA_0 7
SP_Search_DA_0 9
X2LP_Search_DA_0 1103
X5SP_Search_DA_0 3615
Short Square C1SSCOARSE150112_DA_0 632
C1SSFINEST150112_DA_0 1500
SP_Rheo_DA_0 2
X6SP_Rheo_DA_0 781
Short Square - Triple C2SSTRIPLE171103_DA_0 3881
Square - 0.5ms Subthreshold C1SQCAPCHK141203_DA_0 766
Test Blip_finder_DA_0 127
EXTPBREAKN141203_DA_0 1
EXTPBREAKN180424_DA_0 1
EXTPEXPEND180424_DA_0 2
EXTPINBATH141203_DA_0 11
Rheobase_finder_DA_0 130
Unknown C2CHIRP171103_DA_0 10
C2CHIRP171129_DA_0 366
C2CHIRP180503_DA_0 345
Nuc_IC_0_DA_0 6
Nuc_IC_1_DA_0 1
long-square sweeps: 5441 in 318 files; bridge balance 4.3 to 27.5 MOhm; bias current -283.8 to 195.2 pA (1165 sweeps without one)
long-square step durations (s): [1.0] | amplitudes -253.00001525878906 to 770.0 pA
step onset after the experiment epoch start (s): [np.float64(0.5)]
long squares per file: recorded {'min': 7.0, '50%': 12.0, 'max': 50.0} | passing sweep QC {'min': 0.0, '50%': 10.0, 'max': 47.0} | total passing 3847 of 4990
cell QC (computed, not used to drop cells): fail 35 of 318
IPFX version 2.1.2
long squares passing IPFX's sweep QC: 4531 | passing the Methods' sweep QC (IPFX's plus bias current and bridge balance): 3847 of 4990
long-square sweeps failing, by reason (a sweep can have several): {'methods: bridge balance over 15% of Rin': 469, 'Vm delta': 386, 'methods: bias current': 179, 'slow noise': 124, 'methods: bridge balance': 105, 'pre-noise': 6, 'post-noise': 3}
bias current of long squares, as IPFX reads it: -283.8 to 195.2 pA, 179 outside +/-100 pA, 1118 with no value (kept)
input resistance from IPFX's cell QC (for the 15% bridge balance limit): 36 to 654 MOhm, missing in 0 files
files with features: Methods' sweep QC 280 | IPFX's sweep QC alone 307 | files where any feature differs between the two: 40
files without features, and why (long squares passing the Methods' QC and IPFX's QC alone; IPFX's error):
cell_name n_ls_passed n_ls_passed_ipfx features_under_ipfx_qc error
0 H17.06.003.11.07.04 0 35 True KeyError: 'stimulus_amplitude'
8 H16.03.007.01.01.05.10 0 38 True KeyError: 'stimulus_amplitude'
9 H17.06.007.11.04.04 1 10 True FeatureError: Cannot fit f-I curve slope with less than two sweeps
15 H17.03.006.11.08.02 1 1 False IndexError: All stimuli have identical amplitudes
25 H17.03.007.11.06.01 0 35 True KeyError: 'stimulus_amplitude'
29 H17.03.008.11.06.06 0 30 True KeyError: 'stimulus_amplitude'
34 H17.06.009.11.06.09 14 32 True FeatureError: No subthreshold long square sweeps with stim_amp in range [(-100.0, 0)] Cannot evaluate cell features.
37 H17.03.009.11.06.04 0 39 True KeyError: 'stimulus_amplitude'
38 H17.03.009.11.08.03 9 22 True FeatureError: No spiking long square sweeps, cannot compute cell features.
40 H17.03.009.11.08.09 12 25 True FeatureError: No spiking long square sweeps, cannot compute cell features.
58 H17.03.016.11.04.04 0 8 True IndexError: Cannot find {'Long Square SupraThreshold', 'Long Square', 'Long Square Threshold', 'Long Square SubThreshold'} sweeps with clamp mode: CurrentClamp
60 H18.06.001.11.11.04 5 5 False FeatureError: No subthreshold long square sweeps, cannot evaluate cell features.
66 H18.03.005.11.09.03 3 3 False FeatureError: Cannot fit f-I curve slope with less than two sweeps
82 H18.03.006.11.02.02 0 21 True IndexError: Cannot find {'Long Square SupraThreshold', 'Long Square', 'Long Square Threshold', 'Long Square SubThreshold'} sweeps with clamp mode: CurrentClamp
87 H18.03.008.11.12.02 8 13 True FeatureError: No subthreshold long square sweeps with stim_amp in range [(-100, 0)] Cannot evaluate cell features.
99 H18.03.010.11.14.01 8 8 False FeatureError: Cannot fit f-I curve slope with less than two sweeps
111 H18.03.010.11.15.08 7 7 False FeatureError: No spiking long square sweeps, cannot compute cell features.
119 H18.03.012.11.07.02.04 6 6 False FeatureError: Cannot fit f-I curve slope with less than two sweeps
122 H18.06.358.11.06.04 2 2 False FeatureError: No spiking long square sweeps, cannot compute cell features.
132 H18.06.359.11.10.01.03 4 4 False FeatureError: No subthreshold long square sweeps with stim_amp in range [(-100, 0)] Cannot evaluate cell features.
150 H18.03.313.11.14.01.07 6 16 True FeatureError: Cannot fit f-I curve slope with less than two sweeps
152 H18.03.313.11.04.01.02 0 9 True IndexError: Cannot find {'Long Square SupraThreshold', 'Long Square', 'Long Square Threshold', 'Long Square SubThreshold'} sweeps with clamp mode: CurrentClamp
163 H18.03.314.11.05.01.09 1 1 False FeatureError: Cannot fit f-I curve slope with less than two sweeps
181 H18.03.315.11.03.01.01 0 9 True TypeError: cannot unpack non-iterable NoneType object
196 H18.03.317.13.03.01.03 11 11 False FeatureError: No spiking long square sweeps, cannot compute cell features.
214 H18.03.317.13.13.01.04 0 17 True TypeError: cannot unpack non-iterable NoneType object
219 H18.03.318.11.09.01.08 0 11 True TypeError: cannot unpack non-iterable NoneType object
238 H18.03.319.11.10.01.03 0 8 True IndexError: Cannot find {'Long Square SupraThreshold', 'Long Square', 'Long Square Threshold', 'Long Square SubThreshold'} sweeps with clamp mode: CurrentClamp
247 H18.03.319.11.14.01.02 0 9 True TypeError: cannot unpack non-iterable NoneType object
252 H18.03.319.11.10.01.07 0 9 True TypeError: cannot unpack non-iterable NoneType object
255 H18.03.319.11.14.01.05 0 8 True TypeError: cannot unpack non-iterable NoneType object
256 H18.03.319.11.14.01.04 0 9 True TypeError: cannot unpack non-iterable NoneType object
280 H18.03.322.11.11.01.02 16 16 False ValueError: `ydata` must not be empty!
291 H18.03.322.11.15.01.05 0 11 True IndexError: Cannot find {'Long Square SupraThreshold', 'Long Square', 'Long Square Threshold', 'Long Square SubThreshold'} sweeps with clamp mode: CurrentClamp
298 H18.06.371.13.05.01.05 0 16 True TypeError: cannot unpack non-iterable NoneType object
301 H18.06.371.13.05.01.07 0 29 True TypeError: cannot unpack non-iterable NoneType object
302 H18.06.371.13.05.01.10 0 18 True TypeError: cannot unpack non-iterable NoneType object
304 H18.06.371.13.12.01.06 0 10 True TypeError: cannot unpack non-iterable NoneType object
feature ranges (all files):
unit n min median max
adapt_mean ratio 264 0.013266 0.105088 0.980568
avg_rate_hero Hz 280 1.0 7.0 21.0
downstroke_long_square mV/ms 280 -137.465542 -90.563637 -43.526607
fast_trough_v_long_square_rel mV 280 -21.812504 -11.512501 0.40625
fi_fit_slope Hz/pA 272 0.0 0.114492 0.375
first_isi_hero_inv Hz 252 1.246393 22.036144 178.571429
input_resistance MOhm 280 30.781212 112.148415 571.874817
latency_rheo s 280 0.03854 0.1579 0.79404
peak_v_long_square_rel mV 280 59.843752 85.234379 96.437508
rheobase_i pA 280 10.0 119.999992 580.0
sag ratio 279 0.000158 0.048905 0.322434
tau s 280 0.008425 0.020912 0.077768
threshold_v_long_square mV 280 -53.781254 -37.740627 -23.187502
trough_v_long_square_rel mV 280 -23.706249 -14.231251 0.281254
upstroke_downstroke_ratio_long_square ratio 280 2.226772 3.344994 6.602109
upstroke_long_square mV/ms 280 159.848993 308.835744 484.194866
v_baseline mV 280 -87.897484 -70.462955 -52.113964
width_long_square s 280 0.00068 0.00096 0.00176
upward 0 mV crossings in QC-passed long squares: 10489 during the step, 0 in the 1 s before it (0 files with any before)
rheobase sweep: IPFX threshold times against processing/spikes in 280 files; same spike count in 280; largest time difference 0.000 ms (median 0.000)
Link: features-and-labels-link¶
The dandiset's recordings can be matched to the paper's per-cell table (t-type and depth) by specimen ID, and the 18 features computed from them agree with the paper's feature table.
The files carry no SpecimenID. The criterion, as updated after the question, names two readings of the match and asks for both: (M1) a SpecimenID stored in the files, and (M2) the SpecimenID recovered from the file, the smallest SpecimenID of the same donor in the code's table that is above the file's session id, with the code's per-cell features as the check. M2 is a reconstruction that neither the paper nor the code states. It is also checked against a match made on the features alone.
tab = cell_tab.set_index("SpecimenID")
etab = ephys_tab.set_index("specimen_id")
for k in P.DROP_NONPOSITIVE:
etab[k] = etab[k].where(etab[k] > 0)
etab_h = etab.loc[etab.index.isin(tab.index)].dropna(how="all") # human cells with features in the code
ids_in_files = set(cells.session_id) | set(cells.subject_id)
print("M1: files whose session or subject id is a SpecimenID of the cell table:", len(ids_in_files & set(tab.index)),
"| of the feature table:", len(ids_in_files & set(etab.index)))
print("donors: in the files", cells.donor.nunique(), "| in the cell table", tab.donor.nunique(),
"| file donors found in the table", cells.donor.isin(tab.donor).groupby(cells.donor).first().sum())
rows = []
for r in cells.itertuples():
cand = np.sort(tab.index[tab.donor == r.donor].to_numpy())
after = cand[cand > r.session_id]
rows.append(dict(path=r.path, specimen_id=after[0] if len(after) else np.nan,
offset=after[0] - r.session_id if len(after) else np.nan,
gap_to_next=after[1] - after[0] if len(after) > 1 else np.nan, n_donor_cells=len(cand)))
cells = cells.merge(pd.DataFrame(rows), on="path")
print(f"\nM2: files with a candidate {cells.specimen_id.notna().sum()} of {len(cells)}; distinct candidates "
f"{cells.specimen_id.nunique()}; offset {cells.offset.min():.0f} to {cells.offset.max():.0f} "
f"(median {cells.offset.median():.0f}); next candidate of the donor a further {cells.gap_to_next.min():.0f} "
f"or more above")
print("cell-table cells with a file:", cells.specimen_id.nunique(), "of", len(tab),
"| the code's human cells with features that have a file:", int(etab_h.index.isin(cells.specimen_id).sum()),
"of", len(etab_h))
# features computed here against the code's feature table, for the matched cells
m = cells[cells.specimen_id.isin(etab_h.index) & cells.error.isna()].set_index("specimen_id")
mine, ref = m[F].astype(float), etab_h.loc[m.index, F]
rel = (mine - ref).abs() / ref.abs()
both = mine.notna() & ref.notna()
agree = pd.DataFrame({"n_both": both.sum(), "median_rel_diff": rel.where(both).median(),
"share_within_10pct": (rel <= 0.1).where(both).mean(),
"share_identical": ((mine - ref).abs() <= 1e-6 * ref.abs() + 1e-12).where(both).mean(),
"here_not_code": (mine.notna() & ref.isna()).sum(), "code_not_here": (mine.isna() & ref.notna()).sum()})
print(f"\nmatched cells with features both here and in the code: {len(m)}")
print(agree.round(3).to_string())
n_within = int((agree.median_rel_diff <= 0.1).sum())
print("features whose median relative difference is within 10%:", n_within, "of 18")
same_cell = ((mine - ref).abs() <= 1e-6 * ref.abs() + 1e-12).where(both).mean(axis=1)
print(f"cells with every shared feature identical: {(same_cell == 1).sum()}; with at least 80% identical: "
f"{(same_cell >= 0.8).sum()}; lowest share {same_cell.min():.2f}")
# the same comparison with the features under IPFX's sweep QC alone (the variant)
ma = cells[cells.specimen_id.isin(etab_h.index)].set_index("specimen_id") # with the files that give no features
mine_i, ref_a = ma[G].astype(float).set_axis(F, axis=1), etab_h.loc[ma.index, F]
both_i = mine_i.notna() & ref_a.notna()
same_i = ((mine_i - ref_a).abs() <= 1e-6 * ref_a.abs() + 1e-12).where(both_i)
print(f"variant, IPFX's sweep QC alone: median relative difference within 10% for "
f"{int(((mine_i - ref_a).abs() / ref_a.abs()).where(both_i).median().le(0.1).sum())} of 18 features; values on both sides "
f"{int(both_i.sum().sum())} (Methods' QC {int(both.sum().sum())}); cells with every shared feature identical "
f"{int((same_i.mean(axis=1) == 1).sum())}; the code's cells with features that have none here: "
f"{int((ma[G].isna().all(axis=1)).sum())} (Methods' QC {int((ma[F].isna().all(axis=1)).sum())})")
# a match on the features alone, within donor
Fm = [f for f in F if f != "adapt_mean"]
agree_n = tot = 0
for r in cells[cells.error.isna()].itertuples():
cand = etab_h[etab_h.index.isin(tab.index[tab.donor == r.donor])]
if not len(cand) or r.specimen_id not in etab_h.index:
continue
d = ((cand[Fm] - pd.Series({f: getattr(r, f) for f in Fm})).abs() / cand[Fm].abs()).median(axis=1)
tot += 1
agree_n += int(d.idxmin() == r.specimen_id)
print(f"feature-only match within donor picks the M2 cell for {agree_n} of {tot} files whose M2 cell has features in the code")
# the same match with the features under IPFX's sweep QC alone, which reaches the cells that give no features
# under the Methods' sweep QC
Gm = ["ipfxqc_" + f for f in Fm]
agree_i = tot_i = agree_22 = tot_22 = 0
for r in cells[cells[G].notna().any(axis=1)].itertuples():
if r.specimen_id not in etab_h.index:
continue
cand = etab_h[etab_h.index.isin(tab.index[tab.donor == r.donor])]
v = pd.Series({f: getattr(r, g) for f, g in zip(Fm, Gm)}, dtype=float)
d = ((cand[Fm] - v).abs() / cand[Fm].abs()).median(axis=1)
hit = int(d.idxmin() == r.specimen_id)
tot_i += 1
agree_i += hit
if not pd.isna(r.error): # no features under the Methods' sweep QC
tot_22 += 1
agree_22 += hit
print(f"variant, IPFX's sweep QC alone: the feature-only match picks the M2 cell for {agree_i} of {tot_i} files whose M2 "
f"cell has features in the code; of them, files with no features under the Methods' sweep QC: {agree_22} of {tot_22}")
# M2, file by file: the offset and the gap to the donor's next SpecimenID, for the cells the features check (the
# code's 283) and for the 35 they cannot (no features in the code's table)
cells["in283"] = cells.specimen_id.isin(etab_h.index)
print("\nM2 offset and gap to the next candidate, by whether the code's table has features for the cell:")
print(cells.groupby("in283").agg(files=("path", "size"), offset_min=("offset", "min"), offset_median=("offset", "median"),
offset_max=("offset", "max"), gap_min=("gap_to_next", "min"),
no_next_candidate=("gap_to_next", lambda x: int(x.isna().sum()))).to_string())
# checks that do not use the features: the date in the cell's sample_id (rig_YYMMDD_tube_...) against the file's
# local recording date, and, within one rig and day, tube numbers rising with recording time
lk = cells[["cell_name", "session_id", "specimen_id", "offset", "gap_to_next", "session_start", "in283"]].copy()
lk["sample_id"] = tab.loc[lk.specimen_id, "sample_id"].values
parts = lk.sample_id.str.split("_")
lk["rig"], lk["sample_date"], lk["tube"] = parts.str[0], parts.str[1], parts.str[2].astype(int)
t_utc = pd.to_datetime(lk.session_start, utc=True)
lk["local_start"] = t_utc.dt.tz_convert("America/Los_Angeles")
lk["file_date"] = lk.local_start.dt.strftime("%y%m%d")
lk["date_ok"] = lk.file_date == lk.sample_date
print("\nsample_id date equals the file's local (Seattle) recording date:",
lk.groupby("in283").date_ok.agg(["sum", "size"]).rename(columns={"sum": "equal", "size": "files"}).to_dict("index"))
print("files where it does not:")
print(lk.loc[~lk.date_ok, ["cell_name", "local_start", "sample_id", "in283"]].to_string(index=False))
groups = viol = n_in = 0
for _, g in lk.assign(t=t_utc).groupby(["rig", "sample_date"]):
if len(g) > 1:
groups += 1
n_in += len(g)
viol += int(not (np.diff(g.sort_values("t").tube.to_numpy()) > 0).all())
multi = lk.groupby(["rig", "sample_date"]).specimen_id.transform("size") > 1
print(f"rig-days with two or more files: {groups} ({n_in} files); tube numbers out of recording order in {viol}; "
f"of the 35, {int((multi & ~lk.in283).sum())} are in such a rig-day")
print("\nthe 35 cells the features cannot check:")
print(lk.loc[~lk.in283, ["cell_name", "session_id", "specimen_id", "offset", "gap_to_next", "sample_id", "file_date", "date_ok"]]
.to_string(index=False))
# donor-level agreement: sex and age, against the cell table and the code's donor table
dn = cells.groupby("donor").agg(sex=("sex", "first"), age=("age", "first"))
dn["age_y"] = dn.age.str.extract(r"P([\d.]+)D")[0].astype(float) / 365.25
td = tab.groupby("donor").agg(gender=("gender", "first"), age_tab=("age", "first"))
dt = donor_tab.set_index("Donor")[["Gender", "Age (yr)"]]
dd = dn.join(td).join(dt)
dd["age_tab"] = pd.to_numeric(dd.age_tab, errors="coerce")
dd["sex_tab"] = dd.gender.str[0].str.upper().where(dd.gender.isin(["male", "female"]))
for name, sex_col, age_col in [("cell table", "sex_tab", "age_tab"), ("donor table", "Gender", "Age (yr)")]:
ks, ka = dd[sex_col].notna(), dd[age_col].notna()
bad_s = dd.index[ks & (dd.sex != dd[sex_col])].tolist()
bad_a = dd.index[ka & ((dd.age_y - dd[age_col]).abs() >= 1)].tolist()
print(f"{name}: donors listed {int(dd[sex_col].notna().sum())} (sex), {int(ka.sum())} (age); sex differs for {bad_s}; "
f"age differs by a year or more for {bad_a}")
print(dd.loc[dd.index.isin(["H18.03.318", "H18.06.005"]), ["sex", "age_y", "gender", "age_tab", "Gender", "Age (yr)"]].round(2).to_string())
print("t-type or depth stored in the files: none (no such field in the listing above)")
link_ok = (cells.specimen_id.nunique() >= 283) and n_within == 18
print("\ncriterion under M2: at least 283 cells matched:", cells.specimen_id.nunique() >= 283,
"| all 18 features within 10%:", n_within == 18)
M1: files whose session or subject id is a SpecimenID of the cell table: 0 | of the feature table: 0
donors: in the files 56 | in the cell table 82 | file donors found in the table 56
M2: files with a candidate 318 of 318; distinct candidates 318; offset 13 to 685 (median 34); next candidate of the donor a further 28 or more above
cell-table cells with a file: 318 of 385 | the code's human cells with features that have a file: 283 of 283
matched cells with features both here and in the code: 261
n_both median_rel_diff share_within_10pct share_identical here_not_code code_not_here
adapt_mean 247 0.0 0.983806 0.975709 0 1
avg_rate_hero 261 0.0 0.980843 0.980843 0 0
downstroke_long_square 261 0.0 0.996169 0.969349 0 0
fast_trough_v_long_square_rel 261 0.0 0.988506 0.97318 0 0
fi_fit_slope 252 0.0 0.984127 0.97619 1 3
first_isi_hero_inv 236 0.0 0.983051 0.974576 0 0
input_resistance 261 0.0 0.980843 0.716475 0 0
latency_rheo 261 0.0 0.988506 0.97318 0 0
peak_v_long_square_rel 261 0.0 0.992337 0.97318 0 0
rheobase_i 261 0.0 0.996169 0.996169 0 0
sag 260 0.0 0.988462 0.757692 0 0
tau 261 0.0 0.988506 0.881226 0 0
threshold_v_long_square 261 0.0 0.996169 0.97318 0 0
trough_v_long_square_rel 261 0.0 0.984674 0.969349 0 0
upstroke_downstroke_ratio_long_square 261 0.0 0.992337 0.969349 0 0
upstroke_long_square 261 0.0 0.992337 0.97318 0 0
v_baseline 261 0.0 0.996169 0.954023 0 0
width_long_square 261 0.0 0.992337 0.97318 0 0
features whose median relative difference is within 10%: 18 of 18
cells with every shared feature identical: 128; with at least 80% identical: 248; lowest share 0.00
variant, IPFX's sweep QC alone: median relative difference within 10% for 18 of 18 features; values on both sides 5015 (Methods' QC 4649); cells with every shared feature identical 145; the code's cells with features that have none here: 1 (Methods' QC 22)
feature-only match within donor picks the M2 cell for 261 of 261 files whose M2 cell has features in the code
variant, IPFX's sweep QC alone: the feature-only match picks the M2 cell for 282 of 282 files whose M2 cell has features in the code; of them, files with no features under the Methods' sweep QC: 21 of 21
M2 offset and gap to the next candidate, by whether the code's table has features for the cell:
files offset_min offset_median offset_max gap_min no_next_candidate
in283
False 35 13 23.0 375 28.0 9
True 283 13 36.0 685 29.0 46
sample_id date equals the file's local (Seattle) recording date: {False: {'equal': 35, 'files': 35}, True: {'equal': 279, 'files': 283}}
files where it does not:
cell_name local_start sample_id in283
H18.03.314.11.10.01.14 2018-08-08 01:24:15.050-07:00 PBS4_180807_517_A01 True
H18.03.314.11.10.01.13 2018-08-08 01:07:00.148-07:00 PBS4_180807_516_A01 True
H18.06.368.11.14.01.02 2018-11-21 00:31:49.215-08:00 PES4_181120_656_A01 True
H18.03.322.11.10.01.09 2018-11-28 00:28:37.093-08:00 P2S4_181127_057_A01 True
rig-days with two or more files: 71 (253 files); tube numbers out of recording order in 0; of the 35, 27 are in such a rig-day
the 35 cells the features cannot check:
cell_name session_id specimen_id offset gap_to_next sample_id file_date date_ok
H17.06.007.11.04.04 576140380 576140393 13 NaN P2S4_170323_056_A01 170323 True
H17.03.006.11.08.02 591411317 591411338 21 10721.0 P2S4_170524_052_A01 170524 True
H17.26.003.11.25.01 650074923 650074936 13 NaN P6S4_171127_251_A01 171127 True
H18.06.001.11.11.04 660494058 660494076 18 NaN P8S4_180201_356_A01 180201 True
H18.03.005.11.09.03 674615711 674615724 13 20404.0 P2S4_180320_056_A01 180320 True
H18.03.005.11.11.05 674635802 674636128 326 7033.0 P9S4_180320_412_A01 180320 True
H18.03.007.11.05.03 680581408 680581533 125 NaN P2S4_180327_057_A01 180327 True
H18.03.010.11.14.01 695494540 695494556 16 1869.0 P8S4_180508_357_A01 180508 True
H18.03.010.11.15.03 695510684 695510699 15 28.0 P2S4_180508_056_A01 180508 True
H18.03.010.11.15.08 695574422 695574435 13 532245.0 P2S4_180508_061_A01 180508 True
H18.03.010.11.11.08 696109719 696109866 147 1887.0 PBS4_180508_514_A01 180508 True
H18.03.012.11.07.02.04 700826467 700826482 15 17091.0 P2S4_180522_054_A01 180522 True
H18.03.012.11.11.02.04 701072579 701072592 13 NaN P1S4_180522_004_A01 180522 True
H18.06.358.11.06.04 707833431 707833551 120 NaN P8S4_180611_359_A01 180611 True
H18.06.359.11.10.01.03 717087410 717087449 39 7163.0 P8S4_180705_353_A01 180705 True
H18.03.313.11.19.01.04 720845905 720845918 13 4259.0 P9S4_180717_413_A01 180717 True
H18.03.314.11.05.01.09 732159482 732159495 13 11120.0 P2S4_180807_062_A01 180807 True
H18.03.315.11.11.01.02 737134060 737134157 97 24500.0 PBS4_180815_502_A01 180815 True
H18.06.363.11.15.02.03 738027216 738027231 15 NaN P2S4_180816_053_A01 180816 True
H18.03.317.13.03.01.03 758305117 758305130 13 195.0 PES4_180925_654_A01 180925 True
H18.03.317.13.04.01.02 758704139 758704376 237 59472.0 PBS4_180926_502_A01 180926 True
H18.03.317.13.23.01.01 758522739 758523114 375 139097.0 P1S4_180926_001_A01 180926 True
H18.03.317.12.16.01.07 758996791 758996848 57 NaN PES4_180926_656_A01 180926 True
H18.06.366.15.18.01.02 767061006 767061167 161 99462.0 PES4_181022_658_A01 181022 True
H18.03.318.11.09.01.08 767433000 767433014 14 396764.0 PES4_181023_658_A01 181023 True
H18.06.367.11.13.01.02 768848080 768848167 87 367.0 P8S4_181025_354_A01 181025 True
H18.03.319.11.10.01.06 770466500 770466523 23 96.0 PAS4_181030_456_A01 181030 True
H18.03.319.11.14.01.05 770544130 770544209 79 37707.0 P2S4_181030_055_A01 181030 True
H18.03.319.11.14.01.08 770645870 770645883 13 4322.0 P2S4_181030_058_A01 181030 True
H18.06.368.11.02.01.01 783624413 783624438 25 74063.0 P2S4_181120_051_A01 181120 True
H18.03.322.11.03.01.01 786437712 786437731 19 6251.0 PES4_181127_654_A01 181127 True
H18.06.371.13.05.01.01 793375116 793375469 353 58207.0 PES4_181211_651_A01 181211 True
H18.06.371.13.05.01.05 793560108 793560315 207 55449.0 PES4_181211_654_A01 181211 True
H18.06.371.13.05.01.07 793615707 793615764 57 31945.0 PES4_181211_655_A01 181211 True
H18.06.371.13.12.01.06 794299380 794299406 26 NaN PAS4_181212_455_A01 181212 True
cell table: donors listed 48 (sex), 41 (age); sex differs for ['H18.03.318']; age differs by a year or more for ['H18.06.005']
donor table: donors listed 56 (sex), 56 (age); sex differs for ['H18.03.318']; age differs by a year or more for ['H18.06.005']
sex age_y gender age_tab Gender Age (yr)
donor
H18.03.318 F 59.96 male 60.0 M 60
H18.06.005 F 55.96 female 57.0 F 57
t-type or depth stored in the files: none (no such field in the listing above)
criterion under M2: at least 283 cells matched: True | all 18 features within 10%: True
Result: reproduced under reading M2; under reading M1 no cell is linked. No file carries a SpecimenID, so M1 matches 0 files and would give not reproduced. Under M2 the file's session id lies 13 to 685 below one SpecimenID of the same donor, and taking that next id gives 318 distinct cells of the 385-cell table (at least 283, as the criterion asks), including all 283 cells that have features in the code. With the Methods' sweep QC, 261 of them have features both here and in the code; the median relative difference is 0 for all 18 features, 128 cells agree on every shared feature and 248 on at least 80% of them, and a match on the features alone within donor picks the same cell in 261 of 261 files. With IPFX's sweep QC alone the agreement is closer (145 cells identical on every shared feature, and 1 of the code's cells without features here against 22), and the match on features alone picks the M2 cell for 282 of 282 files, among them 21 of 21 that give no features under the Methods' sweep QC; the one cell left (H18.03.322.11.11.01.02) gives features under neither. So the code's table was not made with the Methods' bias current and bridge balance limits as they are applied here. The 35 cells that have no features in the code cannot be checked by features. Two checks that do not use features are consistent with their links: the date in the cell's sample_id equals the file's local recording date for all 35 (and for 279 of the 283; the other 4 started between 00:28 and 01:24, the day after the sample's date), and in each of the 71 rig-days with two or more files (253 files, 27 of the 35 among them) tube numbers rise with recording time without exception. Their M2 offsets (13 to 375) lie within those of the checked cells (13 to 685). The date check separates only cells recorded on different days, so these checks support the 35 links without proving them. At the donor level, sex differs for one donor (H18.03.318) and age by a year or more for one (H18.06.005). The files hold no t-type or depth.
Every claim below that needs a t-type, a depth or a region uses reading M2 of the link: the labels
come from the code's table through the recovered SpecimenID. Under reading M1 none of them could be
tested, since no cell is linked. The features are those under the Methods' sweep QC; df_ipfx holds
the same cells with the features under IPFX's sweep QC alone, used in the section on cell sets.
# The analysis frame: every file, its matched cell's labels from the code's table, and the features computed here.
lab = tab.loc[cells.specimen_id]
df = cells.assign(tt=lab.SeuratMapping.str.split().str[-1].values, nd=lab.L23_depth_normalized.values,
region=lab.region.values, in283=cells.specimen_id.isin(etab_h.index).values)
df["deep_frem3"] = (df.tt == "FREM3") & (df.nd > 0.575)
HOM, DEEP = ["LTK", "GLP2R", "FREM3"], ["deep FREM3", "CARM1P1", "COL22A1"]
df["deep_group"] = np.where(df.deep_frem3, "deep FREM3", np.where(df.tt.isin(["CARM1P1", "COL22A1"]), df.tt, None))
nmiss = df[F].isna().sum(axis=1)
# the variant: the same cells with the features under IPFX's sweep QC alone (the first round's features)
df_ipfx = df.copy()
df_ipfx[F] = df[G].to_numpy()
print(df.tt.value_counts().to_string())
print("cells with a normalized depth:", int(df.nd.notna().sum()), "| regions", df.region.value_counts().to_dict())
def anova(d, group, feats=F):
"""The t-type ANOVA of the claims file for every feature, BH over the features."""
out = pd.DataFrame([dict(feature=f, **P.ols_hc3(d, f, group)) for f in feats])
out["p_bh"] = P.bh(out.p)
return out.sort_values("r2", ascending=False).reset_index(drop=True)
def depth_regression(d, feats=F):
out = pd.DataFrame([dict(feature=f, **P.ols_hc3(d, f, "nd", categorical=False)) for f in feats])
out["r"] = np.sign(out.slope) * np.sqrt(out.r2)
out["p_bh"] = P.bh(out.p)
return out.sort_values("r2", ascending=False).reset_index(drop=True)
tt
FREM3 159
LTK 77
COL22A1 38
GLP2R 25
CARM1P1 19
cells with a normalized depth: 288 | regions {'temporal': 290, 'frontal': 21, 'parietal': 7}
cohort-cells¶
385 Patch-seq neurons passing transcriptomic QC mapped to the five supragranular glutamatergic t-types, and 283 of them had recordings complete enough to compute electrophysiological features.
n385 = int(df.specimen_id.notna().sum())
print("cells of the code's 385-cell table with a recording here:", n385, "(expected 385)")
print("files without a cell of the table under M2:", int(df.specimen_id.isna().sum()),
"(M2 gives every file whose donor is in the table a candidate, so this count cannot find other cells; "
"the date and tube checks of the link are the evidence that the 318 are the table's cells)")
readings = {"(a) at least one feature": nmiss < 18, "(b) all 18": nmiss == 0, "(c) at most 3 of 18 missing": nmiss <= 3}
for k, v in readings.items():
print(f"{k}: {int(v.sum())} (expected 283)")
print("\nvariant: cells with features in the code's own table:", len(etab_h), "| of them with a file here:",
int(df.in283.sum()))
print("cells with features here but none in the code's table:", int(((nmiss < 18) & ~df.in283).sum()),
"| of them failing cell QC:", int(((nmiss < 18) & ~df.in283 & df.cell_qc_failed.astype(bool)).sum()))
print("the code's cells with features that give none here:", int((df.in283 & (nmiss == 18)).sum()))
print("\nby donor: files per donor", df.groupby("donor").size().describe()[["min", "50%", "max"]].to_dict())
nmiss_i = df_ipfx[F].isna().sum(axis=1)
print("variant, IPFX's sweep QC alone: (a)", int((nmiss_i < 18).sum()), "(b)", int((nmiss_i == 0).sum()), "(c)", int((nmiss_i <= 3).sum()))
print("the code's cells with features that give none here: Methods' QC", int((df.in283 & (nmiss == 18)).sum()),
"| IPFX's QC alone", int((df.in283 & (nmiss_i == 18)).sum()))
cohort_cells_match = {k: (n385 == 385, int(v.sum()) == 283) for k, v in readings.items()}
print(cohort_cells_match)
cells of the code's 385-cell table with a recording here: 318 (expected 385)
files without a cell of the table under M2: 0 (M2 gives every file whose donor is in the table a candidate, so this count cannot find other cells; the date and tube checks of the link are the evidence that the 318 are the table's cells)
(a) at least one feature: 280 (expected 283)
(b) all 18: 241 (expected 283)
(c) at most 3 of 18 missing: 280 (expected 283)
variant: cells with features in the code's own table: 283 | of them with a file here: 283
cells with features here but none in the code's table: 19 | of them failing cell QC: 2
the code's cells with features that give none here: 22
by donor: files per donor {'min': 1.0, '50%': 3.0, 'max': 25.0}
variant, IPFX's sweep QC alone: (a) 307 (b) 256 (c) 306
the code's cells with features that give none here: Methods' QC 22 | IPFX's QC alone 1
{'(a) at least one feature': (False, False), '(b) all 18': (False, False), '(c) at most 3 of 18 missing': (False, False)}
Result: not reproduced. 318 cells of the code's 385-cell table have a recording here, not 385, and the cells with features number 280, 241 and 280 under readings (a), (b) and (c), not 283; with IPFX's sweep QC alone they are 307, 256 and 307. The code's own table has features for exactly 283 cells, and all 283 have a file here; 22 of them give no features here under the Methods' sweep QC (1 under IPFX's alone), and 19 further cells give features here but have none in the code (2 of them fail cell QC). M2 gives every file a cell of the table, so no other cell can be found among the files and none is counted apart.
cohort-donors¶
The neurons came from neurosurgical specimens of 90 tissue donors.
print("(a) subjects in the dandiset:", cells.subject_id.nunique())
print("(b) donors of the code's table cells that are here:", df.loc[df.specimen_id.notna(), "donor"].nunique())
print("for reference: donors in the code's 385-cell table", tab.donor.nunique(), "| of its 283 cells with features",
tab.loc[etab_h.index, "donor"].nunique(), "| in the pathology table",
path_tab.donor_id.str[:10].nunique(), "(rows", len(path_tab), ")")
print("pathology donors with a file here:", int(path_tab.donor_id.str[:10].isin(cells.donor).sum()))
(a) subjects in the dandiset: 56 (b) donors of the code's table cells that are here: 56 for reference: donors in the code's 385-cell table 82 | of its 283 cells with features 54 | in the pathology table 89 (rows 90 ) pathology donors with a file here: 52
Result: not reproduced. Both readings give 56 donors, not 90. The code's cell table has 82 donors (54 among its 283 cells with features) and the pathology table 89, of which 52 have a file here.
cohort-type-counts¶
The electrophysiology figures show 66 LTK, 25 GLP2R and 136 FREM3 neurons, and 21 deep FREM3, 17 CARM1P1 and 37 COL22A1 neurons.
expected_counts = pd.Series({"LTK": 66, "GLP2R": 25, "FREM3": 136, "deep FREM3": 21, "CARM1P1": 17, "COL22A1": 37})
def type_counts(d):
return pd.Series({"LTK": (d.tt == "LTK").sum(), "GLP2R": (d.tt == "GLP2R").sum(), "FREM3": (d.tt == "FREM3").sum(),
"deep FREM3": d.deep_frem3.sum(), "CARM1P1": (d.tt == "CARM1P1").sum(),
"COL22A1": (d.tt == "COL22A1").sum()})
ct = pd.DataFrame({k: type_counts(df[v]) for k, v in readings.items()})
ct["variant: the code's 283"] = type_counts(df[df.in283])
ct["variant: IPFX's sweep QC, (a)"] = type_counts(df_ipfx[nmiss_i < 18])
ct["all files"] = type_counts(df)
ct.insert(0, "expected", expected_counts)
print(ct.to_string())
print("\nmatches per reading:", {k: int((ct[k] == ct.expected).sum()) for k in list(readings) + ["variant: the code's 283"]})
print("FREM3 cells without a depth:", int(((df.tt == "FREM3") & df.nd.isna()).sum()))
expected (a) at least one feature (b) all 18 (c) at most 3 of 18 missing variant: the code's 283 variant: IPFX's sweep QC, (a) all files
LTK 66 71 62 71 67 75 77
GLP2R 25 24 23 24 25 25 25
FREM3 136 136 112 136 143 156 159
deep FREM3 21 24 16 24 25 28 28
CARM1P1 17 16 12 16 17 18 19
COL22A1 37 33 32 33 31 33 38
matches per reading: {'(a) at least one feature': 1, '(b) all 18': 0, '(c) at most 3 of 18 missing': 1, "variant: the code's 283": 2}
FREM3 cells without a depth: 13
Result: not reproduced. At most one of the six counts matches under any reading: readings (a) and (c) give 71 LTK, 24 GLP2R, 136 FREM3, 24 deep FREM3, 16 CARM1P1 and 33 COL22A1 (FREM3 matches), and reading (b) gives 62, 23, 112, 16, 12 and 32 (none). The code's own 283 cells give 67, 25, 143, 25, 17 and 31 (two match), and IPFX's sweep QC alone, reading (a), gives 75, 25, 156, 28, 18 and 33 (one).
fig3d-depth-by-type¶
LTK neurons lie mainly in L2 and at the L2/L3 border, GLP2R mainly in upper L3, FREM3 span L2 and L3 and continue into L4, and CARM1P1 and COL22A1 lie almost entirely in deep L3 and along the L3/L4 border.
def depth_summary(d):
g = d.dropna(subset=["nd"]).groupby("tt").nd
return pd.DataFrame({"n": g.size(), "median": g.median(), "min": g.min(), "max": g.max(),
"share_deeper_0.575": g.apply(lambda x: (x > 0.575).mean()),
"share_deeper_1": g.apply(lambda x: (x > 1).mean())}).loc[P.TYPE_ORDER]
def fig3d_verdict(s, d):
ltk_med = s.loc["LTK", "median"]
fre = d.loc[(d.tt == "FREM3"), "nd"].dropna()
parts = {"LTK median below GLP2R median": ltk_med < s.loc["GLP2R", "median"],
"GLP2R median below 0.575": s.loc["GLP2R", "median"] < 0.575,
"FREM3 has cells shallower than the LTK median": (fre < ltk_med).any(),
"FREM3 has cells deeper than 1": (fre > 1).any()}
for th in (0.9, 0.8):
parts[f"CARM1P1 and COL22A1 at least {th:.0%} deeper than 0.575"] = bool(
(s.loc[["CARM1P1", "COL22A1"], "share_deeper_0.575"] >= th).all())
return parts
full = tab.assign(tt=tab.SeuratMapping.str.split().str[-1], nd=tab.L23_depth_normalized)
s_full = depth_summary(full)
print("judged, as the criterion says: every cell of the code's table with a depth, with or without features")
print(s_full.round(3).to_string())
v_full = fig3d_verdict(s_full, full)
for k, v in v_full.items():
print(f" {k}: {v}")
s_here = depth_summary(df)
print("\nvariant: the cells with a recording here (reading M2 of the link)")
print(s_here.round(3).to_string())
for k, v in fig3d_verdict(s_here, df).items():
print(f" {k}: {v}")
print("\nper donor: donors contributing CARM1P1", df[df.tt == "CARM1P1"].donor.nunique(), "| COL22A1",
df[df.tt == "COL22A1"].donor.nunique(), "| depths range", df.nd.min().round(3), "to", df.nd.max().round(3))
fig, ax = plt.subplots(figsize=(6, 3))
for i, t in enumerate(P.TYPE_ORDER):
y = df.loc[df.tt == t, "nd"].dropna()
ax.scatter(np.full(len(y), i) + rng_for("fig3d-depth-by-type").uniform(-0.2, 0.2, len(y)), y, s=6)
ax.axhline(0.575, ls="--", c="k", lw=0.8)
ax.axhline(1, c="k", lw=0.8)
ax.set_xticks(range(5), P.TYPE_ORDER)
ax.invert_yaxis()
ax.set_ylabel("normalized L2/3 depth")
plt.show()
print("all", int(df.nd.notna().sum()), "points are inside the axes")
judged, as the criterion says: every cell of the code's table with a depth, with or without features
n median min max share_deeper_0.575 share_deeper_1
tt
LTK 73 0.086 0.001 0.998 0.041 0.000
GLP2R 25 0.425 0.036 1.141 0.200 0.040
FREM3 158 0.235 0.001 0.992 0.190 0.000
CARM1P1 18 0.852 0.667 0.959 1.000 0.000
COL22A1 30 0.929 0.110 1.165 0.967 0.267
LTK median below GLP2R median: True
GLP2R median below 0.575: True
FREM3 has cells shallower than the LTK median: True
FREM3 has cells deeper than 1: False
CARM1P1 and COL22A1 at least 90% deeper than 0.575: True
CARM1P1 and COL22A1 at least 80% deeper than 0.575: True
variant: the cells with a recording here (reading M2 of the link)
n median min max share_deeper_0.575 share_deeper_1
tt
LTK 70 0.082 0.001 0.998 0.043 0.000
GLP2R 25 0.425 0.036 1.141 0.200 0.040
FREM3 146 0.236 0.001 0.992 0.192 0.000
CARM1P1 18 0.852 0.667 0.959 1.000 0.000
COL22A1 29 0.933 0.775 1.165 1.000 0.276
LTK median below GLP2R median: True
GLP2R median below 0.575: True
FREM3 has cells shallower than the LTK median: True
FREM3 has cells deeper than 1: False
CARM1P1 and COL22A1 at least 90% deeper than 0.575: True
CARM1P1 and COL22A1 at least 80% deeper than 0.575: True
per donor: donors contributing CARM1P1 11 | COL22A1 27 | depths range 0.001 to 1.165
all 288 points are inside the axes
Result: partially reproduced. Over every cell of the code's table with a depth, as the criterion says, the order of medians holds (LTK 0.086 below GLP2R 0.425, GLP2R below 0.575), FREM3 has cells shallower than the LTK median, and 100% of CARM1P1 (18) and 96.7% of COL22A1 (30) cells lie deeper than 0.575, so both readings of "almost entirely" hold. No FREM3 cell lies deeper than 1 (deepest 0.992), so "continuing into L4" does not hold. The cells with a recording here give the same (LTK median 0.082, all 29 COL22A1 deeper than 0.575).
fig4e-human-ephys-anova¶
Among the three human homologous t-types (LTK, GLP2R, FREM3), 3 of 18 electrophysiological features explain more than 10% of variance by t-type (input resistance, f-I slope and rheobase), at FDR below 1e-5, with a maximum R2 of 0.16.
NAMED_H = {"input_resistance", "fi_fit_slope", "rheobase_i"}
def fig4e_human_verdict(res):
big = res[res.r2 > 0.1]
exact = set(big.feature) == NAMED_H and (big.p_bh < 1e-5).all() and abs(res.r2.max() - 0.16) <= 0.016
partial = (res[res.feature.isin(NAMED_H)].pipe(lambda r: ((r.r2 > 0.1) & (r.p_bh < 0.05)).sum()) >= 2)
return "reproduced" if exact else ("partially_reproduced" if partial else "not_reproduced")
hom = df[df.tt.isin(HOM)]
res_h = anova(hom, "tt")
print("cells per type (with any feature):", hom[nmiss[hom.index] < 18].tt.value_counts().to_dict())
print(res_h.round(6).to_string())
print("features with R2 > 0.1:", list(res_h.feature[res_h.r2 > 0.1]), "| max R2", round(res_h.r2.max(), 4),
"| verdict:", fig4e_human_verdict(res_h))
sup = df[df.tt.isin(["LTK", "GLP2R"]) | ((df.tt == "FREM3") & (df.nd < 0.575))]
res_sup = anova(sup, "tt")
print("\nvariant (the code's revision): superficial FREM3 only, n FREM3 =", int((sup.tt == "FREM3").sum()))
print(res_sup.head(6).round(6).to_string(), "\nverdict:", fig4e_human_verdict(res_sup))
res_283 = anova(hom[hom.in283], "tt")
print("\nvariant: the code's 283 cells only")
print(res_283.head(6).round(6).to_string(), "\nverdict:", fig4e_human_verdict(res_283))
# resampling donors, for how much the result rests on a few donors
r = rng_for("fig4e-human-ephys-anova")
donors = hom.donor.unique()
boot = []
for _ in range(200):
pick = r.choice(donors, len(donors), replace=True)
d = pd.concat([hom[hom.donor == x] for x in pick], ignore_index=True)
boot.append({f: P.ols_hc3(d, f, "tt")["r2"] for f in sorted(NAMED_H)})
boot = pd.DataFrame(boot)
print(f"\n{len(donors)} donors; R2 over 200 donor resamples (2.5, 50, 97.5 percentiles):")
print(boot.quantile([0.025, 0.5, 0.975]).round(3).to_string())
cells per type (with any feature): {'FREM3': 136, 'LTK': 71, 'GLP2R': 24}
feature n r2 p slope p_bh
0 input_resistance 231 0.148890 0.000000 NaN 0.000000
1 first_isi_hero_inv 206 0.137392 0.000000 NaN 0.000000
2 adapt_mean 216 0.117101 0.000000 NaN 0.000000
3 rheobase_i 231 0.109726 0.000000 NaN 0.000000
4 downstroke_long_square 231 0.099920 0.000022 NaN 0.000056
5 fi_fit_slope 224 0.099311 0.000017 NaN 0.000050
6 avg_rate_hero 231 0.081063 0.000108 NaN 0.000243
7 sag 230 0.079401 0.000004 NaN 0.000013
8 upstroke_downstroke_ratio_long_square 231 0.064338 0.000135 NaN 0.000269
9 width_long_square 231 0.056908 0.002352 NaN 0.004233
10 latency_rheo 231 0.030187 0.028409 NaN 0.045006
11 v_baseline 231 0.029871 0.030004 NaN 0.045006
12 peak_v_long_square_rel 231 0.017778 0.059207 NaN 0.081979
13 tau 231 0.015281 0.192810 NaN 0.231082
14 threshold_v_long_square 231 0.014786 0.111583 NaN 0.143464
15 trough_v_long_square_rel 231 0.012264 0.268478 NaN 0.284271
16 upstroke_long_square 231 0.009355 0.205406 NaN 0.231082
17 fast_trough_v_long_square_rel 231 0.008194 0.450314 NaN 0.450314
features with R2 > 0.1: ['input_resistance', 'first_isi_hero_inv', 'adapt_mean', 'rheobase_i'] | max R2 0.1489 | verdict: partially_reproduced
variant (the code's revision): superficial FREM3 only, n FREM3 = 118
feature n r2 p slope p_bh
0 input_resistance 196 0.156647 0.000000 NaN 0.000000
1 rheobase_i 196 0.129981 0.000000 NaN 0.000001
2 first_isi_hero_inv 174 0.121906 0.000001 NaN 0.000004
3 adapt_mean 188 0.101517 0.000017 NaN 0.000076
4 fi_fit_slope 193 0.094840 0.000098 NaN 0.000353
5 downstroke_long_square 196 0.083732 0.000408 NaN 0.001223
verdict: partially_reproduced
variant: the code's 283 cells only
feature n r2 p slope p_bh
0 input_resistance 215 0.169772 0.000000 NaN 0.000000
1 adapt_mean 202 0.139254 0.000000 NaN 0.000000
2 fi_fit_slope 208 0.135470 0.000001 NaN 0.000002
3 rheobase_i 215 0.132125 0.000000 NaN 0.000000
4 first_isi_hero_inv 193 0.130795 0.000000 NaN 0.000000
5 downstroke_long_square 215 0.102201 0.000049 NaN 0.000109
verdict: partially_reproduced
51 donors; R2 over 200 donor resamples (2.5, 50, 97.5 percentiles):
fi_fit_slope input_resistance rheobase_i
0.025 0.036 0.087 0.066
0.500 0.106 0.152 0.114
0.975 0.191 0.231 0.167
Result: partially reproduced. Four features have R2 above 0.1, all at BH p below 1e-5: input resistance (0.149), initial firing rate (0.137), adaptation (0.117) and rheobase (0.110). f-I slope has 0.099. The maximum R2 of 0.149 is within 0.16 +/- 0.016, but the features above 0.1 are not the three named. Input resistance and rheobase satisfy the partial criterion. On the code's 283 cells six features exceed 0.1 (maximum 0.170), the three named among them, so the outcome there is partial too; with IPFX's sweep QC alone on those cells it is reproduced (section on cell sets). Over 200 donor resamples the R2 of f-I slope ranges from 0.036 to 0.191 (2.5 to 97.5%).
fig4e-mouse-ephys-anova¶
Among the three mouse L2/3 t-types, 3 of 18 electrophysiological features explain more than 10% of variance (input resistance, AP width and AP downstroke rate), at FDR below 0.05, with a maximum R2 of 0.12, below the human maximum.
The mouse recordings are not in this dandiset; their features and t-types come from the code's tables.
NAMED_M = {"input_resistance", "width_long_square", "downstroke_long_square"}
mt = mouse_tab.set_index("SpecimenID")
mt["tt"] = mt.SeuratMapping.str.split().str[-1]
mo = mt[["tt", "donor_mouse", "L23_depth_normalized"]].join(etab[F], how="inner")
mo = mo[mo[F].notna().any(axis=1)]
print("mouse cells with features:", len(mo), mo.tt.value_counts().to_dict(), "| mice", mo.donor_mouse.nunique())
res_m = anova(mo, "tt")
print(res_m.round(6).to_string())
big = res_m[res_m.r2 > 0.1]
named_ok = res_m[res_m.feature.isin(NAMED_M)].pipe(lambda r: ((r.r2 > 0.1) & (r.p_bh < 0.05)).sum())
exact = set(big.feature) == NAMED_M and (big.p_bh < 0.05).all() and abs(res_m.r2.max() - 0.12) <= 0.012 \
and res_m.r2.max() < res_h.r2.max()
print("features with R2 > 0.1:", list(big.feature), "| max R2", round(res_m.r2.max(), 4), "| human max",
round(res_h.r2.max(), 4), "| named features with R2 > 0.1 at FDR < 0.05:", int(named_ok),
"| verdict:", "reproduced" if exact else ("partially_reproduced" if named_ok >= 2 else "not_reproduced"))
mouse cells with features: 120 {'Agmat': 60, 'Rrad': 51, 'Adamts2': 9} | mice 72
feature n r2 p slope p_bh
0 downstroke_long_square 120 0.122708 0.000536 NaN 0.008326
1 input_resistance 117 0.117814 0.002931 NaN 0.012837
2 width_long_square 120 0.115987 0.001388 NaN 0.008326
3 upstroke_downstroke_ratio_long_square 120 0.084561 0.016525 NaN 0.049575
4 first_isi_hero_inv 114 0.082878 0.003566 NaN 0.012837
5 sag 119 0.063791 0.466162 NaN 0.645455
6 latency_rheo 120 0.063688 0.038019 NaN 0.089302
7 rheobase_i 120 0.049901 0.001108 NaN 0.008326
8 fi_fit_slope 116 0.040519 0.108697 NaN 0.217394
9 avg_rate_hero 120 0.035547 0.129529 NaN 0.233153
10 fast_trough_v_long_square_rel 120 0.028382 0.179853 NaN 0.294305
11 trough_v_long_square_rel 120 0.023647 0.039690 NaN 0.089302
12 upstroke_long_square 120 0.022982 0.255865 NaN 0.383797
13 peak_v_long_square_rel 120 0.009858 0.577215 NaN 0.742134
14 threshold_v_long_square 120 0.004500 0.828608 NaN 0.966184
15 tau 120 0.003040 0.896620 NaN 0.966184
16 adapt_mean 119 0.001627 0.912507 NaN 0.966184
17 v_baseline 120 0.000440 0.976297 NaN 0.976297
features with R2 > 0.1: ['downstroke_long_square', 'input_resistance', 'width_long_square'] | max R2 0.1227 | human max 0.1489 | named features with R2 > 0.1 at FDR < 0.05: 3 | verdict: reproduced
Result: reproduced (on the code's mouse features). Exactly downstroke (0.123), input resistance (0.118) and AP width (0.116) have R2 above 0.1, each at BH p below 0.013, with a maximum of 0.123, below the human maximum of 0.149, over 120 mouse cells (60 Agmat, 51 Rrad, 9 Adamts2).
fig4-glp2r-sag¶
GLP2R neurons, like LTK neurons, lack firing rate adaptation and have higher input resistance, but unlike LTK neurons (which have no sag) they have pronounced sag.
pw = pd.concat([P.pairwise_mw(hom, f, "tt", HOM) for f in ["sag", "adapt_mean", "input_resistance"]])
print(pw.round(5).to_string(index=False))
sag_lg = pw[(pw.feature == "sag") & (pw.a == "LTK") & (pw.b == "GLP2R")].iloc[0]
ad_lg = pw[(pw.feature == "adapt_mean") & (pw.a == "LTK") & (pw.b == "GLP2R")].iloc[0]
print(f"\nsag: GLP2R median {sag_lg.median_b:.4f} against LTK {sag_lg.median_a:.4f}, BH p {sag_lg.p_bh:.2g}")
print(f"adaptation: GLP2R median {ad_lg.median_b:.4f} against LTK {ad_lg.median_a:.4f}, BH p {ad_lg.p_bh:.2g}")
pw283 = pd.concat([P.pairwise_mw(hom[hom.in283], f, "tt", HOM) for f in ["sag", "adapt_mean"]])
print("\nvariant: the code's 283 cells")
print(pw283[(pw283.a == "LTK") & (pw283.b == "GLP2R")].round(5).to_string(index=False))
feature a b n_a n_b median_a median_b p p_bh
sag LTK GLP2R 70 24 0.02548 0.05374 0.03051 0.04576
sag LTK FREM3 70 136 0.02548 0.05153 0.00000 0.00001
sag GLP2R FREM3 24 136 0.05374 0.05153 0.49893 0.49893
adapt_mean LTK GLP2R 69 23 0.05678 0.06003 0.36722 0.36722
adapt_mean LTK FREM3 69 124 0.05678 0.14626 0.00000 0.00000
adapt_mean GLP2R FREM3 23 124 0.06003 0.14626 0.00589 0.00883
input_resistance LTK GLP2R 71 24 122.18761 128.04679 0.38466 0.38466
input_resistance LTK FREM3 71 136 122.18761 90.23436 0.00000 0.00000
input_resistance GLP2R FREM3 24 136 128.04679 90.23436 0.00001 0.00001
sag: GLP2R median 0.0537 against LTK 0.0255, BH p 0.046
adaptation: GLP2R median 0.0600 against LTK 0.0568, BH p 0.37
variant: the code's 283 cells
feature a b n_a n_b median_a median_b p p_bh
sag LTK GLP2R 62 24 0.02595 0.05374 0.03296 0.04944
adapt_mean LTK GLP2R 62 23 0.05536 0.06003 0.24112 0.24112
Result: reproduced. GLP2R sag (median 0.054) is above LTK sag (0.025), BH p 0.046, and adaptation does not differ between them (0.060 against 0.057, BH p 0.37). GLP2R input resistance (128 MOhm) is above FREM3 (90, BH p 0.00001) and not different from LTK (122, BH p 0.38). The code's 283 cells give the same (sag BH p 0.049). The sag result is close to the threshold: with cell QC applied its BH p is 0.060 (section on cell sets).
edtable1-species-ephys¶
Between human and mouse homologous t-types, 17 of 18 electrophysiological features differ at FDR below 0.05.
def mw_scipy14(x, y):
"""scipy 1.4's mannwhitneyu default (alternative None): half the two-sided asymptotic p."""
return stats.mannwhitneyu(x, y, alternative="two-sided", use_continuity=True, method="asymptotic").pvalue / 2
def cohen_d(x, y):
return (np.mean(x) - np.mean(y)) / np.sqrt((np.var(x, ddof=1) + np.var(y, ddof=1)) / 2)
rows = []
for f in F:
x, y = hom[f].dropna(), mo[f].dropna()
rows.append(dict(feature=f, n_human=len(x), n_mouse=len(y), student=stats.ttest_ind(x, y).pvalue,
welch=stats.ttest_ind(x, y, equal_var=False).pvalue, d=cohen_d(x, y)))
sp = pd.DataFrame(rows)
sp["student_bh"], sp["welch_bh"] = P.bh(sp.student), P.bh(sp.welch)
hx, my = hom[hom[F].notna().all(axis=1)], mo[mo[F].notna().all(axis=1)]
sp["code_mw_bh"] = P.bh([mw_scipy14(hx[f], my[f]) for f in F])
print(sp.round(6).to_string(index=False))
n_student, n_welch, n_code = (sp.student_bh < 0.05).sum(), (sp.welch_bh < 0.05).sum(), (sp.code_mw_bh < 0.05).sum()
print(f"\nfeatures at BH p < 0.05: Student {n_student}, Welch {n_welch} (expected 17); variant, the code's "
f"Mann-Whitney on {len(hx)} human and {len(my)} mouse cells with all 18 features: {n_code}")
print("not significant: Student", list(sp.feature[sp.student_bh >= 0.05]), "| Welch", list(sp.feature[sp.welch_bh >= 0.05]),
"| code", list(sp.feature[sp.code_mw_bh >= 0.05]))
feature n_human n_mouse student welch d student_bh welch_bh code_mw_bh
adapt_mean 216 119 0.000000 0.000000 0.760545 0.000000 0.000000 0.000000
avg_rate_hero 231 120 0.000000 0.000000 -0.654249 0.000000 0.000000 0.000000
downstroke_long_square 231 120 0.000009 0.000011 -0.507247 0.000012 0.000015 0.000061
fast_trough_v_long_square_rel 231 120 0.000000 0.000000 -1.898902 0.000000 0.000000 0.000000
fi_fit_slope 224 116 0.000002 0.000001 -0.564364 0.000003 0.000002 0.000002
first_isi_hero_inv 206 114 0.000000 0.000000 0.725999 0.000000 0.000000 0.001212
input_resistance 231 117 0.000000 0.000000 0.973255 0.000000 0.000000 0.000000
latency_rheo 231 120 0.000119 0.000584 -0.414112 0.000153 0.000751 0.000022
peak_v_long_square_rel 231 120 0.001355 0.001019 0.368583 0.001626 0.001223 0.000168
rheobase_i 231 120 0.000005 0.000002 -0.532401 0.000008 0.000003 0.000000
sag 230 119 0.000000 0.000000 0.809598 0.000000 0.000000 0.000000
tau 231 120 0.000000 0.000000 1.641974 0.000000 0.000000 0.000000
threshold_v_long_square 231 120 0.001948 0.002004 -0.351389 0.002192 0.002254 0.001259
trough_v_long_square_rel 231 120 0.023850 0.017745 0.261662 0.025253 0.018788 0.001214
upstroke_downstroke_ratio_long_square 231 120 0.000000 0.000000 -1.791601 0.000000 0.000000 0.000000
upstroke_long_square 231 120 0.000000 0.000000 -1.149788 0.000000 0.000000 0.000000
v_baseline 231 120 0.000000 0.000000 0.965827 0.000000 0.000000 0.000000
width_long_square 231 120 0.457266 0.473158 0.082259 0.457266 0.473158 0.113022
features at BH p < 0.05: Student 17, Welch 17 (expected 17); variant, the code's Mann-Whitney on 197 human and 108 mouse cells with all 18 features: 17
not significant: Student ['width_long_square'] | Welch ['width_long_square'] | code ['width_long_square']
Result: reproduced (with the code's mouse features). Student's and Welch's t-tests both find 17 of 18 features different at BH p below 0.05, AP width being the exception (BH p 0.46 and 0.47). The code's Mann-Whitney test also gives 17, with AP width the exception.
edfig6-classifier-human-ephys and edfig6-classifier-mouse-ephys¶
A random forest predicts the homologous human t-type from electrophysiological features with 67% accuracy. The same classifier predicts mouse L2/3 t-types with 54% accuracy, lower than for human.
1000 stratified 70/30 splits with a 600-tree forest each, on four processes (about 5 and 4 minutes in the last run, printed below). Shuffled labels are run on 100 splits, as a reference only.
from joblib import Parallel, delayed
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
def _one_split(X, y, seed, shuffle):
r = np.random.default_rng(seed)
yy = r.permutation(y) if shuffle else y
Xtr, Xte, ytr, yte = train_test_split(X, yy, test_size=0.3, stratify=yy, random_state=int(seed % 2**31))
clf = RandomForestClassifier(n_estimators=600, class_weight="balanced", max_features="sqrt",
min_samples_leaf=2, n_jobs=1, random_state=int(seed % 2**31))
return float((clf.fit(Xtr, ytr).predict(Xte) == yte).mean())
def rf_accuracy(d, claim, n_splits=1000, shuffle=False, feats=F):
"""Mean test accuracy over stratified 70/30 splits, features standardized over all cells.
Cells with a missing electrophysiological feature are dropped (the code drops them); `feats` are the
columns used."""
d = d[d[F].notna().all(axis=1) & d[feats].notna().all(axis=1)]
X = StandardScaler().fit_transform(d[feats].to_numpy(float))
y = d.tt.to_numpy()
seeds = rng_for(claim + ("-shuffled" if shuffle else "")).integers(0, 2**63 - 1, n_splits)
acc = np.array(Parallel(n_jobs=4)(delayed(_one_split)(X, y, s, shuffle) for s in seeds))
return acc, d.tt.value_counts()
t = time.time()
acc_h, n_h = rf_accuracy(hom, "edfig6-classifier-human-ephys")
acc_h0, _ = rf_accuracy(hom, "edfig6-classifier-human-ephys", n_splits=100, shuffle=True)
print("human cells with all 18 features:", n_h.to_dict(), f"| chance by the largest class {n_h.max() / n_h.sum():.3f}")
print(f"mean accuracy over {len(acc_h)} splits {acc_h.mean():.4f} (SD {acc_h.std():.4f}, 2.5-97.5% "
f"{np.quantile(acc_h, 0.025):.3f}-{np.quantile(acc_h, 0.975):.3f}); shuffled labels {acc_h0.mean():.4f}")
acc_h283, n_h283 = rf_accuracy(hom[hom.in283], "edfig6-classifier-human-ephys-283", n_splits=100)
print(f"variant, the code's 283 cells ({n_h283.sum()} with all 18), 100 splits: {acc_h283.mean():.4f}")
print(f"{(time.time() - t) / 60:.1f} min")
human cells with all 18 features: {'FREM3': 112, 'LTK': 62, 'GLP2R': 23} | chance by the largest class 0.569
mean accuracy over 1000 splits 0.6218 (SD 0.0556, 2.5-97.5% 0.517-0.733); shuffled labels 0.4412
variant, the code's 283 cells (184 with all 18), 100 splits: 0.6302 7.2 min
Result: reproduced. The mean test accuracy over 1000 splits is 0.622 (SD 0.056), within 0.67 +/- 0.067, against 0.441 with shuffled labels and 0.569 for always guessing FREM3, so the margin over the largest class is small. The code's 283 cells give 0.630 over 100 splits.
t = time.time()
acc_m, n_m = rf_accuracy(mo, "edfig6-classifier-mouse-ephys")
acc_m0, _ = rf_accuracy(mo, "edfig6-classifier-mouse-ephys", n_splits=100, shuffle=True)
print("mouse cells with all 18 features:", n_m.to_dict(), f"| chance by the largest class {n_m.max() / n_m.sum():.3f}")
print(f"mean accuracy over {len(acc_m)} splits {acc_m.mean():.4f} (SD {acc_m.std():.4f}); shuffled labels "
f"{acc_m0.mean():.4f}; human {acc_h.mean():.4f}")
print(f"{(time.time() - t) / 60:.1f} min")
mouse cells with all 18 features: {'Agmat': 53, 'Rrad': 47, 'Adamts2': 8} | chance by the largest class 0.491
mean accuracy over 1000 splits 0.5713 (SD 0.0709); shuffled labels 0.4209; human 0.6218
6.3 min
Result: reproduced (with the code's mouse features). The mean accuracy over 1000 splits is 0.571 (SD 0.071), within 0.54 +/- 0.054 and below the human 0.622, against 0.421 with shuffled labels and 0.491 for always guessing Agmat.
fig5c-frem3-ephys-depth¶
In FREM3 neurons, 9 of 18 electrophysiological features correlate with normalized depth at FDR below 0.05 (7 at FDR below 0.01); the strongest are increasing sag, increasing AP upstroke/downstroke ratio and decreasing latency at rheobase.
def fig5c_verdict(res):
n05, n01 = (res.p_bh < 0.05).sum(), (res.p_bh < 0.01).sum()
top = res.head(3)
want = {"sag": 1, "upstroke_downstroke_ratio_long_square": 1, "latency_rheo": -1}
top_ok = set(top.feature) == set(want) and all(np.sign(top.set_index("feature").slope[k]) == v for k, v in want.items()) \
and (top.p_bh < 1e-7).all()
three = res.set_index("feature").loc[list(want)]
signs = all(np.sign(three.slope[k]) == v for k, v in want.items()) and (three.p_bh < 0.05).all()
counts_ok = abs(n05 - 9) <= 0.9 and abs(n01 - 7) <= 0.7
return n05, n01, ("reproduced" if counts_ok and top_ok else ("partially_reproduced" if signs else "not_reproduced"))
fre = df[(df.tt == "FREM3") & df.nd.notna()]
res_d = depth_regression(fre)
print("FREM3 cells with a depth:", len(fre), "| donors", fre.donor.nunique())
print(res_d.round(8).to_string())
print("counts at FDR < 0.05, < 0.01, verdict:", fig5c_verdict(res_d))
print("top three, BH p:", {f: f"{p:.4g}" for f, p in zip(res_d.feature[:3], res_d.p_bh[:3])})
res_d283 = depth_regression(fre[fre.in283])
print("\nvariant, the code's 283 cells:", res_d283.head(4)[["feature", "n", "r2", "slope", "p_bh"]].round(8).to_string(),
"\n", fig5c_verdict(res_d283))
FREM3 cells with a depth: 146 | donors 40
feature n r2 p slope r p_bh
0 sag 125 0.486526 0.000000e+00 0.157526 0.697514 0.000000e+00
1 upstroke_downstroke_ratio_long_square 125 0.252173 7.000000e-08 1.283405 0.502168 4.400000e-07
2 latency_rheo 125 0.245806 0.000000e+00 -0.144219 -0.495788 0.000000e+00
3 v_baseline 125 0.195261 2.490000e-06 11.004032 0.441884 8.980000e-06
4 upstroke_long_square 125 0.180446 1.380000e-06 97.891849 0.424789 6.200000e-06
5 first_isi_hero_inv 108 0.133561 2.902700e-04 64.175569 0.365460 8.708100e-04
6 adapt_mean 113 0.081107 1.113340e-03 0.211601 0.284793 2.862870e-03
7 avg_rate_hero 125 0.071989 1.188578e-02 -3.336462 -0.268308 2.674300e-02
8 fi_fit_slope 119 0.054803 5.655140e-02 -0.047775 -0.234101 1.017925e-01
9 peak_v_long_square_rel 125 0.040178 3.682927e-02 5.313709 0.200446 7.365855e-02
10 input_resistance 125 0.019326 1.943214e-01 -19.902005 -0.139016 2.690604e-01
11 threshold_v_long_square 125 0.016705 1.739504e-01 -2.530521 -0.129247 2.609257e-01
12 trough_v_long_square_rel 125 0.013574 2.202830e-01 1.605166 0.116508 2.832211e-01
13 tau 125 0.010523 1.592767e-01 -0.002657 -0.102580 2.606345e-01
14 fast_trough_v_long_square_rel 125 0.010507 2.866894e-01 1.112206 0.102505 3.225256e-01
15 downstroke_long_square 125 0.008288 2.700879e-01 4.337899 0.091039 3.225256e-01
16 width_long_square 125 0.002973 4.950709e-01 0.000025 0.054523 5.241927e-01
17 rheobase_i 125 0.002422 6.407175e-01 15.420842 0.049215 6.407175e-01
counts at FDR < 0.05, < 0.01, verdict: (np.int64(8), np.int64(7), 'partially_reproduced')
top three, BH p: {'sag': '2.646e-15', 'upstroke_downstroke_ratio_long_square': '4.449e-07', 'latency_rheo': '1.817e-09'}
variant, the code's 283 cells: feature n r2 slope p_bh 0 sag 117 0.467827 0.156538 0.000000e+00 1 upstroke_downstroke_ratio_long_square 117 0.261674 1.344795 1.190000e-06 2 latency_rheo 117 0.240057 -0.138931 1.000000e-08 3 v_baseline 117 0.212198 11.676385 8.830000e-06 (np.int64(8), np.int64(6), 'partially_reproduced')
Result: partially reproduced. Over 146 FREM3 cells with a depth from 40 donors (125 with features), 8 features correlate with depth at BH p below 0.05 (outside 9 +/- 0.9) and 7 below 0.01 (as expected). The three largest R2 are sag (0.487, increasing), AP upstroke/downstroke ratio (0.252, increasing) and latency at rheobase (0.246, decreasing), as the claim states, but the ratio's BH p is 4.4e-07, not below 1e-7. The code's 283 cells give 8 and 6, and IPFX's sweep QC alone 10 and 7.
fig6-deep-ephys-anova¶
The three deep L3 types (deep FREM3, CARM1P1, COL22A1) differ in 15 of 18 electrophysiological features (FDR below 0.05), with R2 above 0.4 for 4 of them, while no feature reaches R2 0.4 among the three homologous types.
deep = df[df.deep_group.notna()]
res_deep = anova(deep, "deep_group")
n05, n4 = int((res_deep.p_bh < 0.05).sum()), int((res_deep.r2 > 0.4).sum())
print("cells per group (any feature):", deep[nmiss[deep.index] < 18].deep_group.value_counts().to_dict())
print(res_deep.round(6).to_string())
print(f"features at BH p < 0.05: {n05} (expected 15 +/- 1.5); R2 > 0.4: {n4} (expected 4 +/- 0.4); "
f"homologous-type features with R2 > 0.4: {int((res_h.r2 > 0.4).sum())} (max {res_h.r2.max():.3f})")
res_deep283 = anova(deep[deep.in283], "deep_group")
print(f"variant, the code's 283 cells: {int((res_deep283.p_bh < 0.05).sum())} at BH p < 0.05, "
f"{int((res_deep283.r2 > 0.4).sum())} with R2 > 0.4")
cells per group (any feature): {'COL22A1': 33, 'deep FREM3': 24, 'CARM1P1': 16}
feature n r2 p slope p_bh
0 input_resistance 73 0.600197 0.000000 NaN 0.000000
1 width_long_square 73 0.524515 0.000000 NaN 0.000000
2 rheobase_i 73 0.477587 0.000000 NaN 0.000000
3 downstroke_long_square 73 0.474452 0.000000 NaN 0.000000
4 tau 73 0.394770 0.000000 NaN 0.000000
5 avg_rate_hero 73 0.361061 0.000001 NaN 0.000002
6 upstroke_downstroke_ratio_long_square 73 0.300202 0.000013 NaN 0.000024
7 fi_fit_slope 68 0.293213 0.000036 NaN 0.000058
8 sag 73 0.284765 0.000009 NaN 0.000021
9 adapt_mean 65 0.252380 0.000008 NaN 0.000020
10 upstroke_long_square 73 0.229896 0.000012 NaN 0.000023
11 first_isi_hero_inv 67 0.204148 0.001038 NaN 0.001557
12 latency_rheo 73 0.091362 0.037035 NaN 0.047617
13 threshold_v_long_square 73 0.088025 0.050813 NaN 0.060976
14 v_baseline 73 0.086690 0.022995 NaN 0.031839
15 trough_v_long_square_rel 73 0.054360 0.161301 NaN 0.170790
16 peak_v_long_square_rel 73 0.041054 0.073922 NaN 0.083162
17 fast_trough_v_long_square_rel 73 0.004232 0.860336 NaN 0.860336
features at BH p < 0.05: 14 (expected 15 +/- 1.5); R2 > 0.4: 4 (expected 4 +/- 0.4); homologous-type features with R2 > 0.4: 0 (max 0.149)
variant, the code's 283 cells: 14 at BH p < 0.05, 4 with R2 > 0.4
Result: reproduced. Over 24 deep FREM3, 16 CARM1P1 and 33 COL22A1 cells, 14 features differ at BH p below 0.05, within 15 +/- 1.5, and 4 have R2 above 0.4 (input resistance 0.600, AP width 0.525, rheobase 0.478 and downstroke 0.474), as expected; no homologous-type feature reaches 0.4 (maximum 0.149). The code's 283 cells give 14 and 4 too. With IPFX's sweep QC alone, as in the first round, the counts are 15 and 5 (partially reproduced), and with cell QC applied 12 and 4 (partially reproduced; section on cell sets).
fig6c-carm1p1-upstroke-rin and fig6c-col22a1-rin-fi-sag¶
CARM1P1 neurons have a faster AP upstroke than deep FREM3 and COL22A1 neurons, and a higher input resistance than deep FREM3 neurons.
COL22A1 neurons have very high input resistance and a steeper f-I gain than the other deep L3 types, and less sag than CARM1P1 neurons.
pwd = pd.concat([P.pairwise_mw(deep, f, "deep_group", DEEP) for f in
["upstroke_long_square", "upstroke_downstroke_ratio_long_square", "input_resistance", "fi_fit_slope", "sag"]])
print(pwd.round(5).to_string(index=False))
def higher(feature, a, b):
"""True when group a is significantly above group b (BH p < 0.05 and a larger median)."""
r = pwd[(pwd.feature == feature) & (((pwd.a == a) & (pwd.b == b)) | ((pwd.a == b) & (pwd.b == a)))].iloc[0]
med_a, med_b = (r.median_a, r.median_b) if r.a == a else (r.median_b, r.median_a)
return bool(r.p_bh < 0.05 and med_a > med_b)
up = {f: higher(f, "CARM1P1", "deep FREM3") and higher(f, "CARM1P1", "COL22A1")
for f in ["upstroke_long_square", "upstroke_downstroke_ratio_long_square"]}
rin = higher("input_resistance", "CARM1P1", "deep FREM3")
print("\nCARM1P1 upstroke above both, (a) rate, (b) ratio:", up, "| CARM1P1 Rin above deep FREM3:", rin)
feature a b n_a n_b median_a median_b p p_bh
upstroke_long_square deep FREM3 CARM1P1 24 16 330.37490 370.92293 0.01153 0.01730
upstroke_long_square deep FREM3 COL22A1 24 33 330.37490 297.88356 0.04090 0.04090
upstroke_long_square CARM1P1 COL22A1 16 33 370.92293 297.88356 0.00004 0.00012
upstroke_downstroke_ratio_long_square deep FREM3 CARM1P1 24 16 3.75829 4.63413 0.00601 0.00902
upstroke_downstroke_ratio_long_square deep FREM3 COL22A1 24 33 3.75829 4.82582 0.00001 0.00004
upstroke_downstroke_ratio_long_square CARM1P1 COL22A1 16 33 4.63413 4.82582 0.05367 0.05367
input_resistance deep FREM3 CARM1P1 24 16 86.43633 123.08594 0.00173 0.00173
input_resistance deep FREM3 COL22A1 24 33 86.43633 296.89084 0.00000 0.00000
input_resistance CARM1P1 COL22A1 16 33 123.08594 296.89084 0.00000 0.00000
fi_fit_slope deep FREM3 CARM1P1 20 15 0.05033 0.11698 0.08604 0.08604
fi_fit_slope deep FREM3 COL22A1 20 33 0.05033 0.17019 0.00004 0.00012
fi_fit_slope CARM1P1 COL22A1 15 33 0.11698 0.17019 0.00332 0.00499
sag deep FREM3 CARM1P1 24 16 0.15483 0.13390 0.92302 0.92302
sag deep FREM3 COL22A1 24 33 0.15483 0.06942 0.00037 0.00055
sag CARM1P1 COL22A1 16 33 0.13390 0.06942 0.00001 0.00003
CARM1P1 upstroke above both, (a) rate, (b) ratio: {'upstroke_long_square': True, 'upstroke_downstroke_ratio_long_square': False} | CARM1P1 Rin above deep FREM3: True
Result: blocked, methods underspecified. CARM1P1 input resistance (123 MOhm) is above deep FREM3 (86, BH p 0.0017). CARM1P1 upstroke rate (371 mV/ms) is above deep FREM3 (330, BH p 0.017) and COL22A1 (298, BH p 0.0001), so reading (a) reproduces the claim; but the upstroke/downstroke ratio of CARM1P1 (4.63) is not above that of COL22A1 (4.83, BH p 0.054), so reading (b) gives only the input resistance part. The two readings give different outcomes under every cell set of the section on cell sets.
col = {"input_resistance": higher("input_resistance", "COL22A1", "deep FREM3") and higher("input_resistance", "COL22A1", "CARM1P1"),
"fi_fit_slope": higher("fi_fit_slope", "COL22A1", "deep FREM3") and higher("fi_fit_slope", "COL22A1", "CARM1P1"),
"sag below CARM1P1": higher("sag", "CARM1P1", "COL22A1")}
print(col, "| parts holding:", sum(col.values()), "of 3")
pwd283 = pd.concat([P.pairwise_mw(deep[deep.in283], f, "deep_group", DEEP) for f in
["upstroke_long_square", "upstroke_downstroke_ratio_long_square", "input_resistance", "fi_fit_slope", "sag"]])
print("\nvariant, the code's 283 cells:")
print(pwd283.round(5).to_string(index=False))
{'input_resistance': True, 'fi_fit_slope': True, 'sag below CARM1P1': True} | parts holding: 3 of 3
variant, the code's 283 cells:
feature a b n_a n_b median_a median_b p p_bh
upstroke_long_square deep FREM3 CARM1P1 23 16 329.95222 370.92293 0.01464 0.02196
upstroke_long_square deep FREM3 COL22A1 23 30 329.95222 298.13610 0.07711 0.07711
upstroke_long_square CARM1P1 COL22A1 16 30 370.92293 298.13610 0.00008 0.00025
upstroke_downstroke_ratio_long_square deep FREM3 CARM1P1 23 16 3.65643 4.63413 0.00759 0.01139
upstroke_downstroke_ratio_long_square deep FREM3 COL22A1 23 30 3.65643 4.82682 0.00002 0.00007
upstroke_downstroke_ratio_long_square CARM1P1 COL22A1 16 30 4.63413 4.82682 0.05131 0.05131
input_resistance deep FREM3 CARM1P1 23 16 88.43755 123.08594 0.00259 0.00259
input_resistance deep FREM3 COL22A1 23 30 88.43755 297.27354 0.00000 0.00000
input_resistance CARM1P1 COL22A1 16 30 123.08594 297.27354 0.00000 0.00000
fi_fit_slope deep FREM3 CARM1P1 19 15 0.05536 0.11698 0.11857 0.11857
fi_fit_slope deep FREM3 COL22A1 19 30 0.05536 0.16938 0.00014 0.00042
fi_fit_slope CARM1P1 COL22A1 15 30 0.11698 0.16938 0.00542 0.00813
sag deep FREM3 CARM1P1 23 16 0.15539 0.13390 0.85277 0.85277
sag deep FREM3 COL22A1 23 30 0.15539 0.07047 0.00099 0.00149
sag CARM1P1 COL22A1 16 30 0.13390 0.07047 0.00001 0.00004
Result: reproduced. COL22A1 input resistance (297 MOhm) and f-I slope (0.170 Hz/pA) are each above deep FREM3 (86 MOhm, 0.050) and CARM1P1 (123 MOhm, 0.117), at BH p 0.005 or less, and COL22A1 sag (0.069) is below CARM1P1 (0.134, BH p 0.00003). All three parts hold under every cell set of the section on cell sets.
fig2ef-pathology-ephys¶
Of 18 electrophysiological features compared between neurons from donors with low (0 to 1) and high (1 to 3) GFAP or IBA1 scores, only resting membrane potential under IBA1 differs, neurons from high-IBA1 donors being about 5 mV more hyperpolarized; the other 17 IBA1 and all 18 GFAP comparisons do not differ.
Donor scores come from the code's pathology_scoring.csv, matched on the first 10 characters of
its donor id, as the code does.
pt = path_tab.assign(donor=path_tab.donor_id.str[:10])
print("pathology rows", len(pt), "| distinct donors", pt.donor.nunique())
dup = pt[pt.donor.duplicated(keep=False)]
print("donor with two rows:", dup[["donor_id", "GFAP Cortex", "Iba1 Cortex"]].to_string(index=False),
"\n its files here:", int(df.donor.isin(dup.donor).sum()),
"| in both the low and the high group of a marker:",
{m_: bool((dup[c_] <= 1).any() and (dup[c_] > 1).any()) for m_, c_ in [("GFAP", "GFAP Cortex"), ("IBA1", "Iba1 Cortex")]})
def pathology_test(d, feats_src, two_sided=False):
out = {}
for marker, col in [("GFAP", "GFAP Cortex"), ("IBA1", "Iba1 Cortex")]:
low_d, high_d = set(pt.donor[pt[col] <= 1]), set(pt.donor[pt[col] > 1])
lo, hi = feats_src[d.donor.isin(low_d).values], feats_src[d.donor.isin(high_d).values]
rows = []
for f in F:
x, y = lo[f].dropna(), hi[f].dropna()
p = (stats.mannwhitneyu(x, y, alternative="two-sided").pvalue if two_sided else mw_scipy14(x, y))
rows.append(dict(feature=f, p=p, sig=p < 0.05 / 18, n_low=len(x), n_high=len(y),
median_diff=y.median() - x.median(), mean_diff=y.mean() - x.mean()))
out[marker] = pd.DataFrame(rows)
return out
def pathology_verdict(out):
g, i = out["GFAP"], out["IBA1"]
only_rmp = (not g.sig.any()) and i.sig.sum() == 1 and bool(i.set_index("feature").sig["v_baseline"])
rmp = i.set_index("feature").loc["v_baseline"]
size = [abs(rmp.median_diff - (-5)) <= 0.5, abs(rmp.mean_diff - (-5)) <= 0.5]
if not only_rmp:
return "not_reproduced"
if all(size):
return "reproduced"
return "partially_reproduced" if not any(size) else "methods_underspecified (size)"
all18 = df[nmiss == 0]
for name, d in [("(a) temporal", all18[all18.region == "temporal"]), ("(b) all regions", all18)]:
out = pathology_test(d, d)
print(f"\n{name}: {len(d)} cells with all 18 features")
for marker, r in out.items():
print(f" {marker}: low {r.n_low.max()} high {r.n_high.max()} cells; significant at 0.05/18: "
f"{list(r.feature[r.sig])}; smallest p {r.p.min():.2g} ({r.feature[r.p.idxmin()]})")
rmp = out["IBA1"].set_index("feature").loc["v_baseline"]
print(f" RMP, high minus low IBA1: medians {rmp.median_diff:.2f} mV, means {rmp.mean_diff:.2f} mV, p {rmp.p:.2g}")
print(" verdict:", pathology_verdict(out))
out2 = pathology_test(d, d, two_sided=True)
print(" variant, two-sided test: significant GFAP", list(out2["GFAP"].feature[out2["GFAP"].sig]),
"IBA1", list(out2["IBA1"].feature[out2["IBA1"].sig]))
# the updated notebook: temporal cells of the code's table with all 18 features in the code's own table
ec = etab.loc[etab.index.isin(tab.index)].dropna()
d_upd = tab.loc[ec.index].assign(donor=tab.loc[ec.index].donor)
d_upd = d_upd[d_upd.region == "temporal"]
out_u = pathology_test(d_upd, ec.loc[d_upd.index])
print(f"\nvariant, the updated notebook's procedure on the code's own features ({len(d_upd)} cells): "
f"GFAP {list(out_u['GFAP'].feature[out_u['GFAP'].sig])} (low {out_u['GFAP'].n_low.max()}, high {out_u['GFAP'].n_high.max()}), "
f"IBA1 {list(out_u['IBA1'].feature[out_u['IBA1'].sig])} (low {out_u['IBA1'].n_low.max()}, high {out_u['IBA1'].n_high.max()})")
pathology rows 90 | distinct donors 89
donor with two rows: donor_id GFAP Cortex Iba1 Cortex
H17.06.013.12.02 1.000000 1.000000
H17.06.013.11.13 1.666667 1.666667
its files here: 0 | in both the low and the high group of a marker: {'GFAP': True, 'IBA1': True}
(a) temporal: 224 cells with all 18 features
GFAP: low 73 high 139 cells; significant at 0.05/18: []; smallest p 0.025 (upstroke_long_square)
IBA1: low 187 high 29 cells; significant at 0.05/18: ['v_baseline']; smallest p 0.00089 (v_baseline)
RMP, high minus low IBA1: medians -4.28 mV, means -4.16 mV, p 0.00089
verdict: partially_reproduced
variant, two-sided test: significant GFAP [] IBA1 ['v_baseline']
(b) all regions: 241 cells with all 18 features GFAP: low 86 high 143 cells; significant at 0.05/18: []; smallest p 0.03 (input_resistance) IBA1: low 204 high 29 cells; significant at 0.05/18: ['latency_rheo', 'v_baseline']; smallest p 0.00092 (v_baseline) RMP, high minus low IBA1: medians -4.19 mV, means -4.12 mV, p 0.00092 verdict: not_reproduced
variant, two-sided test: significant GFAP [] IBA1 ['v_baseline']
variant, the updated notebook's procedure on the code's own features (221 cells): GFAP [] (low 74, high 135), IBA1 ['latency_rheo', 'v_baseline'] (low 187, high 26)
Result: partially reproduced. Under reading (a), temporal cells (224 with all 18 features), RMP under IBA1 is the only comparison of 36 below 0.05/18 (p 0.00089), with high-IBA1 cells more hyperpolarized, but by 4.28 mV (medians) and 4.16 mV (means), outside 5 +/- 0.5. Under reading (b), all regions, latency under IBA1 is significant too. Neither reading gives the paper's group sizes (reading (a) has 73 and 139 GFAP, 187 and 29 IBA1 cells, against 60 and 125, 170 and 15). The donor with two rows in the pathology table (H17.06.013, low in one row and high in the other for both markers) has no file here. The updated notebook's procedure on the code's own features finds latency and RMP under IBA1, and so do the code's 283 cells here under reading (a) (section on cell sets).
How the electrophysiology outcomes depend on the cell set and the QC¶
Three choices bear on every claim above: the sweep QC (the Methods', the main reading, or IPFX's alone); whether the 35 cells that have no features in the code's table are kept (their link rests on the date and tube checks of the link, not on the features); and whether the cell QC of the Methods (seal, access resistance), which the claims file does not ask for, is applied. Each claim's verdict function above is run on each cell set. The classifier is run on 50 splits per set, as a reference.
def ephys_outcomes(d):
"""The verdict of each electrophysiology claim above, recomputed on the cell set d."""
o = {}
nm_ = d[F].isna().sum(axis=1)
h_ = d[d.tt.isin(HOM)]
rh = anova(h_, "tt")
o["fig4e-human-ephys-anova"] = (fig4e_human_verdict(rh), f"R2 > 0.1: {', '.join(rh.feature[rh.r2 > 0.1])}; max {rh.r2.max():.3f}")
pw_ = pd.concat([P.pairwise_mw(h_, f, "tt", HOM) for f in ["sag", "adapt_mean"]]).set_index(["feature", "a", "b"])
sg, ad = pw_.loc[("sag", "LTK", "GLP2R")], pw_.loc[("adapt_mean", "LTK", "GLP2R")]
sag_up = sg.p_bh < 0.05 and sg.median_b > sg.median_a
o["fig4-glp2r-sag"] = ("reproduced" if sag_up and ad.p_bh >= 0.05 else ("partially_reproduced" if sag_up else "not_reproduced"),
f"sag BH p {sg.p_bh:.3g}, adaptation BH p {ad.p_bh:.3g}")
pv = pd.DataFrame([dict(s=stats.ttest_ind(h_[f].dropna(), mo[f].dropna()).pvalue,
w=stats.ttest_ind(h_[f].dropna(), mo[f].dropna(), equal_var=False).pvalue) for f in F])
ns, nw = int((P.bh(pv.s) < 0.05).sum()), int((P.bh(pv.w) < 0.05).sum())
o["edtable1-species-ephys"] = ("reproduced" if ns == nw == 17 else ("methods_underspecified" if (ns == 17) != (nw == 17) else "not_reproduced"),
f"Student {ns}, Welch {nw}")
n05_, n01_, v_ = fig5c_verdict(depth_regression(d[(d.tt == "FREM3") & d.nd.notna()]))
o["fig5c-frem3-ephys-depth"] = (v_, f"{n05_} at FDR < 0.05, {n01_} at FDR < 0.01")
dp = d[d.deep_group.notna()]
rd = anova(dp, "deep_group")
a_, b_ = int((rd.p_bh < 0.05).sum()), int((rd.r2 > 0.4).sum())
ca, cb = abs(a_ - 15) <= 1.5, abs(b_ - 4) <= 0.4
o["fig6-deep-ephys-anova"] = ("reproduced" if ca and cb and not (rh.r2 > 0.4).any() else ("partially_reproduced" if ca or cb else "not_reproduced"),
f"{a_} at FDR < 0.05, {b_} with R2 > 0.4")
pwd_ = pd.concat([P.pairwise_mw(dp, f, "deep_group", DEEP) for f in
["upstroke_long_square", "upstroke_downstroke_ratio_long_square", "input_resistance", "fi_fit_slope", "sag"]])
def hi(f, x, y):
r = pwd_[(pwd_.feature == f) & (((pwd_.a == x) & (pwd_.b == y)) | ((pwd_.a == y) & (pwd_.b == x)))].iloc[0]
mx, my = (r.median_a, r.median_b) if r.a == x else (r.median_b, r.median_a)
return bool(r.p_bh < 0.05 and mx > my)
up_ = [hi(f, "CARM1P1", "deep FREM3") and hi(f, "CARM1P1", "COL22A1") for f in ["upstroke_long_square", "upstroke_downstroke_ratio_long_square"]]
rin_ = hi("input_resistance", "CARM1P1", "deep FREM3")
vv = ["reproduced" if u and rin_ else ("partially_reproduced" if u or rin_ else "not_reproduced") for u in up_]
o["fig6c-carm1p1-upstroke-rin"] = (vv[0] if vv[0] == vv[1] else "methods_underspecified",
f"upstroke above both: (a) {up_[0]}, (b) {up_[1]}; Rin above deep FREM3: {rin_}")
parts_ = [hi("input_resistance", "COL22A1", "deep FREM3") and hi("input_resistance", "COL22A1", "CARM1P1"),
hi("fi_fit_slope", "COL22A1", "deep FREM3") and hi("fi_fit_slope", "COL22A1", "CARM1P1"),
hi("sag", "CARM1P1", "COL22A1")]
o["fig6c-col22a1-rin-fi-sag"] = ("reproduced" if all(parts_) else ("partially_reproduced" if sum(parts_) >= 2 else "not_reproduced"),
f"{sum(parts_)} of 3 parts")
a18 = d[nm_ == 0]
order = ["reproduced", "partially_reproduced", "methods_underspecified (size)", "not_reproduced"]
vs, txt = [], []
for name, dd in [("(a)", a18[a18.region == "temporal"]), ("(b)", a18)]:
out = pathology_test(dd, dd)
vs.append(pathology_verdict(out))
r_ = out["IBA1"].set_index("feature").loc["v_baseline"]
txt.append(f"{name} GFAP {list(out['GFAP'].feature[out['GFAP'].sig])}, IBA1 {list(out['IBA1'].feature[out['IBA1'].sig])}, "
f"RMP {r_.median_diff:.2f} mV (medians)")
o["fig2ef-pathology-ephys"] = (min(vs, key=order.index), "; ".join(txt))
return o
cq = ~df.cell_qc_failed.astype(bool)
cell_sets = {
"main: Methods' sweep QC, all linked cells": df,
"Methods' sweep QC, the code's 283 only": df[df.in283],
"Methods' sweep QC, cell QC passed": df[cq],
"Methods' sweep QC, cell QC passed, the code's 283": df[cq & df.in283],
"IPFX's sweep QC (round 1), all linked cells": df_ipfx,
"IPFX's sweep QC, the code's 283 only": df_ipfx[df_ipfx.in283],
"IPFX's sweep QC, cell QC passed": df_ipfx[cq],
}
print("cells failing cell QC: of the code's 283", int((~cq & df.in283).sum()), "| of the 35 others", int((~cq & ~df.in283).sum()))
print("cell QC failures by criterion:", df.loc[~cq, "cell_qc_tags"].str.split("; ").explode().str.split(" ").str[0].value_counts().to_dict())
sens = {k: ephys_outcomes(v) for k, v in cell_sets.items()}
claims_ = list(sens[next(iter(sens))])
print("\nverdicts (rows: cell sets; columns: claims)")
print(pd.DataFrame({c_: {k: v[c_][0] for k, v in sens.items()} for c_ in claims_}).T.to_string())
print("\nthe numbers behind them")
for c_ in claims_:
print(c_)
for k, v in sens.items():
print(f" {k}: {v[c_][1]}")
print("\nedfig6-classifier-human-ephys, mean accuracy over 50 splits (expected 0.67 +/- 0.067):")
for k in ["Methods' sweep QC, the code's 283 only", "Methods' sweep QC, cell QC passed", "IPFX's sweep QC (round 1), all linked cells"]:
hh = cell_sets[k][cell_sets[k].tt.isin(HOM)]
a_, n_ = rf_accuracy(hh, "edfig6-classifier-human-ephys-" + k, n_splits=50)
print(f" {k}: {a_.mean():.4f} ({n_.sum()} cells with all 18 features)")
cells failing cell QC: of the code's 283 29 | of the 35 others 6
cell QC failures by criterion: {'input_access_resistance_ratio': 19, 'seal': 14, 'electrode_0_pa': 3, 'initial_access_resistance_mohm': 2}
verdicts (rows: cell sets; columns: claims)
main: Methods' sweep QC, all linked cells Methods' sweep QC, the code's 283 only Methods' sweep QC, cell QC passed Methods' sweep QC, cell QC passed, the code's 283 IPFX's sweep QC (round 1), all linked cells IPFX's sweep QC, the code's 283 only IPFX's sweep QC, cell QC passed
fig4e-human-ephys-anova partially_reproduced partially_reproduced partially_reproduced partially_reproduced partially_reproduced reproduced partially_reproduced
fig4-glp2r-sag reproduced reproduced not_reproduced not_reproduced reproduced reproduced reproduced
edtable1-species-ephys reproduced reproduced methods_underspecified not_reproduced reproduced methods_underspecified not_reproduced
fig5c-frem3-ephys-depth partially_reproduced partially_reproduced partially_reproduced partially_reproduced partially_reproduced partially_reproduced partially_reproduced
fig6-deep-ephys-anova reproduced reproduced partially_reproduced reproduced partially_reproduced reproduced reproduced
fig6c-carm1p1-upstroke-rin methods_underspecified methods_underspecified methods_underspecified methods_underspecified methods_underspecified methods_underspecified methods_underspecified
fig6c-col22a1-rin-fi-sag reproduced reproduced reproduced reproduced reproduced reproduced reproduced
fig2ef-pathology-ephys partially_reproduced not_reproduced partially_reproduced not_reproduced partially_reproduced not_reproduced not_reproduced
the numbers behind them
fig4e-human-ephys-anova
main: Methods' sweep QC, all linked cells: R2 > 0.1: input_resistance, first_isi_hero_inv, adapt_mean, rheobase_i; max 0.149
Methods' sweep QC, the code's 283 only: R2 > 0.1: input_resistance, adapt_mean, fi_fit_slope, rheobase_i, first_isi_hero_inv, downstroke_long_square; max 0.170
Methods' sweep QC, cell QC passed: R2 > 0.1: input_resistance, first_isi_hero_inv, rheobase_i, adapt_mean; max 0.157
Methods' sweep QC, cell QC passed, the code's 283: R2 > 0.1: input_resistance, rheobase_i, fi_fit_slope, first_isi_hero_inv, adapt_mean; max 0.165
IPFX's sweep QC (round 1), all linked cells: R2 > 0.1: input_resistance, rheobase_i, first_isi_hero_inv; max 0.141
IPFX's sweep QC, the code's 283 only: R2 > 0.1: input_resistance, rheobase_i, fi_fit_slope; max 0.161
IPFX's sweep QC, cell QC passed: R2 > 0.1: input_resistance, rheobase_i; max 0.140
fig4-glp2r-sag
main: Methods' sweep QC, all linked cells: sag BH p 0.0458, adaptation BH p 0.367
Methods' sweep QC, the code's 283 only: sag BH p 0.0494, adaptation BH p 0.241
Methods' sweep QC, cell QC passed: sag BH p 0.0595, adaptation BH p 0.358
Methods' sweep QC, cell QC passed, the code's 283: sag BH p 0.0543, adaptation BH p 0.283
IPFX's sweep QC (round 1), all linked cells: sag BH p 0.0228, adaptation BH p 0.314
IPFX's sweep QC, the code's 283 only: sag BH p 0.0237, adaptation BH p 0.22
IPFX's sweep QC, cell QC passed: sag BH p 0.0307, adaptation BH p 0.266
edtable1-species-ephys
main: Methods' sweep QC, all linked cells: Student 17, Welch 17
Methods' sweep QC, the code's 283 only: Student 17, Welch 17
Methods' sweep QC, cell QC passed: Student 16, Welch 17
Methods' sweep QC, cell QC passed, the code's 283: Student 16, Welch 16
IPFX's sweep QC (round 1), all linked cells: Student 17, Welch 17
IPFX's sweep QC, the code's 283 only: Student 16, Welch 17
IPFX's sweep QC, cell QC passed: Student 16, Welch 16
fig5c-frem3-ephys-depth
main: Methods' sweep QC, all linked cells: 8 at FDR < 0.05, 7 at FDR < 0.01
Methods' sweep QC, the code's 283 only: 8 at FDR < 0.05, 6 at FDR < 0.01
Methods' sweep QC, cell QC passed: 8 at FDR < 0.05, 7 at FDR < 0.01
Methods' sweep QC, cell QC passed, the code's 283: 7 at FDR < 0.05, 6 at FDR < 0.01
IPFX's sweep QC (round 1), all linked cells: 10 at FDR < 0.05, 7 at FDR < 0.01
IPFX's sweep QC, the code's 283 only: 8 at FDR < 0.05, 7 at FDR < 0.01
IPFX's sweep QC, cell QC passed: 10 at FDR < 0.05, 7 at FDR < 0.01
fig6-deep-ephys-anova
main: Methods' sweep QC, all linked cells: 14 at FDR < 0.05, 4 with R2 > 0.4
Methods' sweep QC, the code's 283 only: 14 at FDR < 0.05, 4 with R2 > 0.4
Methods' sweep QC, cell QC passed: 12 at FDR < 0.05, 4 with R2 > 0.4
Methods' sweep QC, cell QC passed, the code's 283: 15 at FDR < 0.05, 4 with R2 > 0.4
IPFX's sweep QC (round 1), all linked cells: 15 at FDR < 0.05, 5 with R2 > 0.4
IPFX's sweep QC, the code's 283 only: 14 at FDR < 0.05, 4 with R2 > 0.4
IPFX's sweep QC, cell QC passed: 14 at FDR < 0.05, 4 with R2 > 0.4
fig6c-carm1p1-upstroke-rin
main: Methods' sweep QC, all linked cells: upstroke above both: (a) True, (b) False; Rin above deep FREM3: True
Methods' sweep QC, the code's 283 only: upstroke above both: (a) True, (b) False; Rin above deep FREM3: True
Methods' sweep QC, cell QC passed: upstroke above both: (a) True, (b) False; Rin above deep FREM3: True
Methods' sweep QC, cell QC passed, the code's 283: upstroke above both: (a) True, (b) False; Rin above deep FREM3: True
IPFX's sweep QC (round 1), all linked cells: upstroke above both: (a) True, (b) False; Rin above deep FREM3: True
IPFX's sweep QC, the code's 283 only: upstroke above both: (a) True, (b) False; Rin above deep FREM3: True
IPFX's sweep QC, cell QC passed: upstroke above both: (a) True, (b) False; Rin above deep FREM3: True
fig6c-col22a1-rin-fi-sag
main: Methods' sweep QC, all linked cells: 3 of 3 parts
Methods' sweep QC, the code's 283 only: 3 of 3 parts
Methods' sweep QC, cell QC passed: 3 of 3 parts
Methods' sweep QC, cell QC passed, the code's 283: 3 of 3 parts
IPFX's sweep QC (round 1), all linked cells: 3 of 3 parts
IPFX's sweep QC, the code's 283 only: 3 of 3 parts
IPFX's sweep QC, cell QC passed: 3 of 3 parts
fig2ef-pathology-ephys
main: Methods' sweep QC, all linked cells: (a) GFAP [], IBA1 ['v_baseline'], RMP -4.28 mV (medians); (b) GFAP [], IBA1 ['latency_rheo', 'v_baseline'], RMP -4.19 mV (medians)
Methods' sweep QC, the code's 283 only: (a) GFAP [], IBA1 ['latency_rheo', 'v_baseline'], RMP -4.35 mV (medians); (b) GFAP [], IBA1 ['latency_rheo', 'v_baseline'], RMP -4.33 mV (medians)
Methods' sweep QC, cell QC passed: (a) GFAP [], IBA1 ['v_baseline'], RMP -4.23 mV (medians); (b) GFAP [], IBA1 ['latency_rheo', 'v_baseline'], RMP -4.23 mV (medians)
Methods' sweep QC, cell QC passed, the code's 283: (a) GFAP [], IBA1 [], RMP -4.19 mV (medians); (b) GFAP [], IBA1 ['latency_rheo', 'v_baseline'], RMP -4.19 mV (medians)
IPFX's sweep QC (round 1), all linked cells: (a) GFAP [], IBA1 ['v_baseline'], RMP -4.10 mV (medians); (b) GFAP [], IBA1 ['fast_trough_v_long_square_rel', 'latency_rheo', 'v_baseline'], RMP -4.10 mV (medians)
IPFX's sweep QC, the code's 283 only: (a) GFAP [], IBA1 ['latency_rheo', 'v_baseline'], RMP -4.44 mV (medians); (b) GFAP [], IBA1 ['latency_rheo', 'v_baseline'], RMP -4.31 mV (medians)
IPFX's sweep QC, cell QC passed: (a) GFAP [], IBA1 ['latency_rheo', 'v_baseline'], RMP -4.21 mV (medians); (b) GFAP [], IBA1 ['latency_rheo', 'v_baseline'], RMP -4.21 mV (medians)
edfig6-classifier-human-ephys, mean accuracy over 50 splits (expected 0.67 +/- 0.067):
Methods' sweep QC, the code's 283 only: 0.6407 (184 cells with all 18 features)
Methods' sweep QC, cell QC passed: 0.6122 (180 cells with all 18 features)
IPFX's sweep QC (round 1), all linked cells: 0.6419 (212 cells with all 18 features)
Result: the outcomes above hold for the main cell set; three choices move some of them. Leaving out the 35 cells without features in the code changes one outcome under the Methods' sweep QC: fig2ef-pathology-ephys becomes not reproduced, as latency under IBA1 is significant too. With IPFX's sweep QC alone (the first round), fig6-deep-ephys-anova is partially reproduced (15 and 5), and on the code's 283 cells fig4e-human-ephys-anova is reproduced (maximum R2 0.161) and edtable1-species-ephys methods underspecified (Student 16, Welch 17). With cell QC applied, fig4-glp2r-sag is not reproduced (sag BH p 0.060), edtable1-species-ephys methods underspecified (Student 16, Welch 17) and fig6-deep-ephys-anova partially reproduced (12 and 4). fig5c-frem3-ephys-depth, fig6c-carm1p1-upstroke-rin and fig6c-col22a1-rin-fi-sag are the same under every set. The classifier gives 0.612 to 0.642 over 50 splits under the three sets run, within 0.67 +/- 0.067.
Claims on data outside the dandiset (elsewhere)¶
These use tables and images from the paper's code repository at commit 3daf9f0, not the dandiset. They are counted apart from the dataset's claims.
fig2d-pathology-scores and edfig1-marker-correlation¶
Average pathology scores over six markers ranged from 0.06 to 1.83 across donors, and most cases had averages below 1.0.
The six pathology markers are very weakly correlated with one another across donors, with only Ki-67 and Nissl (cellularity) modestly correlated.
SIX = ["GFAP Cortex", "Iba1 Cortex", "Ki67", "SMI32 Cortex", "NeuN Orientation Layering", "Cellularity"]
avg = path_tab[SIX].sum(axis=1, min_count=6) / 6
print(f"donors with all six scores: {avg.notna().sum()} of {len(path_tab)}; average {avg.min():.3f} to {avg.max():.3f}; "
f"below 1.0: {(avg < 1).sum()} ({(avg < 1).mean():.1%} of those with all six)")
donors with all six scores: 86 of 90; average 0.056 to 1.833; below 1.0: 78 (86.7% of those with all six)
Result: reproduced. Over the 86 donors with all six scores, the average ranges from 0.056 to 1.833, within the tolerances of 0.06 and 1.83, and 78 (86.7%) are below 1.0.
cor = path_tab[SIX].corr(method="pearson")
pairs = pd.DataFrame([dict(a=a, b=b, r=cor.loc[a, b], n=path_tab[[a, b]].dropna().shape[0]) for a, b in combinations(SIX, 2)])
pairs["abs_r"] = pairs.r.abs()
print(pairs.sort_values("abs_r", ascending=False).round(3).to_string(index=False))
a b r n abs_r
Ki67 Cellularity 0.391 90 0.391
GFAP Cortex Cellularity 0.254 89 0.254
GFAP Cortex Ki67 0.243 89 0.243
SMI32 Cortex NeuN Orientation Layering 0.235 87 0.235
Iba1 Cortex SMI32 Cortex 0.165 89 0.165
Iba1 Cortex Ki67 0.153 90 0.153
GFAP Cortex Iba1 Cortex 0.150 89 0.150
NeuN Orientation Layering Cellularity 0.067 88 0.067
Ki67 NeuN Orientation Layering -0.064 88 0.064
Iba1 Cortex Cellularity -0.050 90 0.050
Iba1 Cortex NeuN Orientation Layering 0.048 88 0.048
SMI32 Cortex Cellularity 0.047 89 0.047
GFAP Cortex NeuN Orientation Layering -0.043 87 0.043
GFAP Cortex SMI32 Cortex 0.038 88 0.038
Ki67 SMI32 Cortex -0.005 89 0.005
Result: reproduced. Ki-67 and cellularity have the largest absolute correlation of the 15 pairs (r = 0.391); the next is 0.254.
Morphological features: fig4f-morph-anova, fig5b-frem3-morph-depth, fig6-deep-morph-anova¶
MF = list(morph_names.iloc[:, 1])
mh = morph_h.set_index("specimen_id").join(tab[["SeuratMapping", "L23_depth_normalized"]], how="inner")
mh["tt"], mh["nd"] = mh.SeuratMapping.str.split().str[-1], mh.L23_depth_normalized
mm_ = morph_m.set_index("specimen_id").join(mt[["tt"]], how="inner")
print("human reconstructions with a t-type:", len(mh), mh.tt.value_counts().to_dict(), "| mouse:", len(mm_), mm_.tt.value_counts().to_dict())
res_mh = anova(mh[mh.tt.isin(HOM)], "tt", MF)
res_mm = anova(mm_, "tt", MF)
# as the code: a feature with no p-value (constant among the cells) is dropped before BH, and R2 is counted over the rest
print("dropped, no p-value: human", list(res_mh.feature[res_mh.p.isna()]), "| mouse", list(res_mm.feature[res_mm.p.isna()]))
big_h, big_m = res_mh[(res_mh.r2 > 0.15) & res_mh.p.notna()], res_mm[(res_mm.r2 > 0.15) & res_mm.p.notna()]
print(f"human, all FREM3: R2 > 0.15 in {len(big_h)} of {int(res_mh.p.notna().sum())} kept (expected 16 +/- 1.6), of them FDR < 1e-3: {(big_h.p_bh < 1e-3).sum()}")
print(f"mouse: R2 > 0.15 in {len(big_m)} of {int(res_mm.p.notna().sum())} kept (expected 12 +/- 1.2), of them FDR < 0.05: {(big_m.p_bh < 0.05).sum()} (paper 10)")
res_mh_sup = anova(mh[mh.tt.isin(["LTK", "GLP2R"]) | ((mh.tt == "FREM3") & (mh.nd < 0.575))], "tt", MF)
print(f"variant, superficial FREM3: R2 > 0.15 in {((res_mh_sup.r2 > 0.15) & res_mh_sup.p.notna()).sum()}, of them FDR < 1e-3: "
f"{((res_mh_sup.r2 > 0.15) & (res_mh_sup.p_bh < 1e-3)).sum()}")
human reconstructions with a t-type: 109 {'FREM3': 58, 'LTK': 25, 'GLP2R': 11, 'COL22A1': 10, 'CARM1P1': 5} | mouse: 60 {'Agmat': 27, 'Rrad': 26, 'Adamts2': 7}
dropped, no p-value: human ['apical_dendrite_pct_below_basal_dendrite_none', 'basal_dendrite_pct_above_apical_dendrite_none'] | mouse ['apical_dendrite_pct_below_basal_dendrite_none'] human, all FREM3: R2 > 0.15 in 16 of 58 kept (expected 16 +/- 1.6), of them FDR < 1e-3: 16 mouse: R2 > 0.15 in 12 of 59 kept (expected 12 +/- 1.2), of them FDR < 0.05: 10 (paper 10)
variant, superficial FREM3: R2 > 0.15 in 10, of them FDR < 1e-3: 2
Result: reproduced. Among the human homologous types two features have no p-value and are dropped, as in the code; 16 of the 58 kept have R2 above 0.15, all 16 at BH p below 1e-3. Among the mouse types one is dropped, and 12 of the 59 kept have R2 above 0.15, 10 of them at BH p below 0.05, as the paper states. With superficial FREM3 only (the code's revision), 10 human features exceed 0.15.
LOC = ["soma_relative_depth_none", "depth_from_pia"]
fm = mh[(mh.tt == "FREM3") & mh.nd.notna()]
r5 = depth_regression(fm, MF)
kept = r5[r5.p.notna()]
print(f"FREM3 reconstructions with a depth: {len(fm)}; features {len(MF)}")
print("dropped before BH, no p-value:", list(r5.feature[r5.p.isna()]),
"| constant among these cells:", [f for f in MF if fm[f].nunique() <= 1])
print(f"over the {len(kept)} kept: FDR < 0.05 {(kept.p_bh < 0.05).sum()} (expected 37 +/- 3.7), "
f"< 0.01 {(kept.p_bh < 0.01).sum()} (expected 28 +/- 2.8)")
r_loc = depth_regression(fm, [f for f in MF if f not in LOC])
print(f"for reference, the earlier reading without the two location features: {int(r_loc.p.notna().sum())} kept, "
f"FDR < 0.05 {(r_loc.p_bh < 0.05).sum()}, < 0.01 {(r_loc.p_bh < 0.01).sum()}")
print(r5.set_index("feature").loc[["apical_dendrite_extent_y", "basal_dendrite_max_path_distance_none", "soma_radius"],
["n", "r", "r2", "p_bh"]].round(6).to_string())
FREM3 reconstructions with a depth: 56; features 60 dropped before BH, no p-value: ['apical_dendrite_pct_below_basal_dendrite_none', 'basal_dendrite_pct_above_apical_dendrite_none'] | constant among these cells: ['apical_dendrite_pct_below_basal_dendrite_none', 'basal_dendrite_pct_above_apical_dendrite_none'] over the 58 kept: FDR < 0.05 37 (expected 37 +/- 3.7), < 0.01 28 (expected 28 +/- 2.8)
for reference, the earlier reading without the two location features: 56 kept, FDR < 0.05 35, < 0.01 26
n r r2 p_bh
feature
apical_dendrite_extent_y 56 0.938245 0.880304 0.000000
basal_dendrite_max_path_distance_none 56 0.736280 0.542108 0.000000
soma_radius 56 0.486947 0.237118 0.017901
Result: reproduced. Of the 60 features, two are constant among the 56 FREM3 reconstructions with a depth and have no p-value; over the 58 kept, as in the code, 37 correlate with depth at BH p below 0.05 and 28 below 0.01, the paper's counts. Apical height (r = 0.94), maximum basal path distance (0.74) and soma radius (0.49, BH p 0.018) are among them. Without the two location features, the earlier reading, the counts are 35 and 26.
mh["deep_group"] = np.where((mh.tt == "FREM3") & (mh.nd > 0.575), "deep FREM3",
np.where(mh.tt.isin(["CARM1P1", "COL22A1"]), mh.tt, None))
dm_ = mh[mh.deep_group.notna()]
res_dm = anova(dm_, "deep_group", MF)
print("reconstructions per deep group:", dm_.deep_group.value_counts().to_dict())
print("dropped before BH, no p-value:", list(res_dm.feature[res_dm.p.isna()]))
print(f"over the {int(res_dm.p.notna().sum())} kept: FDR < 0.05: {(res_dm.p_bh < 0.05).sum()} (expected 24 +/- 2.4); "
f"R2 > 0.4: {((res_dm.r2 > 0.4) & res_dm.p.notna()).sum()} (expected 20 +/- 2)")
reconstructions per deep group: {'COL22A1': 10, 'deep FREM3': 8, 'CARM1P1': 5}
dropped before BH, no p-value: ['basal_dendrite_pct_above_apical_dendrite_none']
over the 59 kept: FDR < 0.05: 24 (expected 24 +/- 2.4); R2 > 0.4: 20 (expected 20 +/- 2)
Result: reproduced. One feature has no p-value among the deep types and is dropped, as in the code; of the 59 kept, 24 differ among the deep types at BH p below 0.05 and 20 have R2 above 0.4, with 8 deep FREM3, 5 CARM1P1 and 10 COL22A1 reconstructions.
fig6a-deep-dendrites¶
CARM1P1 neurons have the largest total dendritic length of the L2 and L3 t-types, with extensive proximal oblique and basal branching, while COL22A1 neurons have very sparse branching.
The criterion, as updated after the question, gives the readings the paper allows: total length is apical plus basal total length; the t-types are (a) the five with FREM3 whole or (b) with FREM3 split at 0.575; largest is by (i) the mean or (ii) the median, with no test. Sparse branching is the fewest apical and basal branches among the three deep types. The outcome must hold under every reading.
mh["total_length"] = mh.apical_dendrite_total_length_none + mh.basal_dendrite_total_length_none
mh["group_b"] = np.where(mh.tt == "FREM3", np.where(mh.nd > 0.575, "deep FREM3", np.where(mh.nd.notna(), "superficial FREM3", None)), mh.tt)
BR = ["apical_dendrite_num_branches_none", "basal_dendrite_num_branches_none"]
cols = ["total_length", "apical_dendrite_total_length_none"] + BR
print("reconstructions without a depth (left out of reading (b)):", mh[mh.tt == "FREM3"].nd.isna().sum(), "FREM3")
fig6a = {}
for gname, g in [("(a) FREM3 whole", "tt"), ("(b) FREM3 split at 0.575", "group_b")]:
agg = mh.dropna(subset=[g]).groupby(g)[cols].agg(["count", "mean", "median"])
print(f"\n{gname}:")
print(agg.round(0).to_string())
for stat in ("mean", "median"):
tl = agg[("total_length", stat)]
fig6a[(gname, stat, "CARM1P1 largest total length")] = tl.idxmax() == "CARM1P1"
print(f" {stat}: largest total length {tl.idxmax()} ({tl.max():.0f} um), next {tl.drop(tl.idxmax()).idxmax()} ({tl.drop(tl.idxmax()).max():.0f} um)")
dg = mh[mh.deep_group.notna()].groupby("deep_group")[["apical_dendrite_total_length_none"] + BR].agg(["mean", "median"])
print("\ndeep types:")
print(dg.round(1).to_string())
for stat in ("mean", "median"):
fig6a[("deep types", stat, "COL22A1 fewest apical and basal branches")] = all(dg[(b, stat)].idxmin() == "COL22A1" for b in BR)
fig6a[("deep types", stat, "CARM1P1 apical length below deep FREM3 (not judged)")] = \
dg.loc["CARM1P1", ("apical_dendrite_total_length_none", stat)] < dg.loc["deep FREM3", ("apical_dendrite_total_length_none", stat)]
print()
for k, v in fig6a.items():
print(" | ".join(k), ":", v)
judged = [v for k, v in fig6a.items() if "not judged" not in k[2]]
print("\nCARM1P1 largest and COL22A1 sparsest under every reading:", all(judged), "| under some:", any(judged))
reconstructions without a depth (left out of reading (b)): 2 FREM3
(a) FREM3 whole:
total_length apical_dendrite_total_length_none apical_dendrite_num_branches_none basal_dendrite_num_branches_none
count mean median count mean median count mean median count mean median
tt
CARM1P1 5 12011.0 10447.0 5 6896.0 5864.0 5 63.0 57.0 5 59.0 58.0
COL22A1 10 4816.0 4462.0 10 3290.0 3314.0 10 24.0 23.0 10 19.0 16.0
FREM3 58 8114.0 7509.0 58 4277.0 4181.0 58 46.0 45.0 58 50.0 46.0
GLP2R 11 5867.0 5955.0 11 3212.0 2988.0 11 33.0 31.0 11 36.0 37.0
LTK 25 4998.0 4576.0 25 2830.0 2669.0 25 33.0 31.0 25 30.0 29.0
mean: largest total length CARM1P1 (12011 um), next FREM3 (8114 um)
median: largest total length CARM1P1 (10447 um), next FREM3 (7509 um)
(b) FREM3 split at 0.575:
total_length apical_dendrite_total_length_none apical_dendrite_num_branches_none basal_dendrite_num_branches_none
count mean median count mean median count mean median count mean median
group_b
CARM1P1 5 12011.0 10447.0 5 6896.0 5864.0 5 63.0 57.0 5 59.0 58.0
COL22A1 10 4816.0 4462.0 10 3290.0 3314.0 10 24.0 23.0 10 19.0 16.0
GLP2R 11 5867.0 5955.0 11 3212.0 2988.0 11 33.0 31.0 11 36.0 37.0
LTK 25 4998.0 4576.0 25 2830.0 2669.0 25 33.0 31.0 25 30.0 29.0
deep FREM3 8 11566.0 12024.0 8 5443.0 5540.0 8 56.0 57.0 8 78.0 78.0
superficial FREM3 48 7396.0 6801.0 48 4014.0 3898.0 48 44.0 43.0 48 44.0 42.0
mean: largest total length CARM1P1 (12011 um), next deep FREM3 (11566 um)
median: largest total length deep FREM3 (12024 um), next CARM1P1 (10447 um)
deep types:
apical_dendrite_total_length_none apical_dendrite_num_branches_none basal_dendrite_num_branches_none
mean median mean median mean median
deep_group
CARM1P1 6896.1 5863.6 63.4 57.0 58.8 58.0
COL22A1 3290.4 3313.9 24.2 23.0 19.4 15.5
deep FREM3 5443.1 5540.2 56.2 57.0 78.4 77.5
(a) FREM3 whole | mean | CARM1P1 largest total length : True
(a) FREM3 whole | median | CARM1P1 largest total length : True
(b) FREM3 split at 0.575 | mean | CARM1P1 largest total length : True
(b) FREM3 split at 0.575 | median | CARM1P1 largest total length : False
deep types | mean | COL22A1 fewest apical and basal branches : True
deep types | mean | CARM1P1 apical length below deep FREM3 (not judged) : False
deep types | median | COL22A1 fewest apical and basal branches : True
deep types | median | CARM1P1 apical length below deep FREM3 (not judged) : False
CARM1P1 largest and COL22A1 sparsest under every reading: False | under some: True
Result: blocked, methods underspecified (the readings differ). With FREM3 whole, CARM1P1 has the largest total dendritic length by mean (12011 um) and median (10447 um). With FREM3 split at 0.575, CARM1P1 is largest by mean (12011 um against 11566 for deep FREM3) but deep FREM3 is largest by median (12024 um against 10447). COL22A1 has the fewest apical and basal branches of the deep types by mean and median (24 and 19 by mean, against at least 56 and 59). The apical part does not hold: CARM1P1's apical length (mean 6896 um) is above that of deep FREM3 (5443 um).
edfig6-classifier-morphoelectric¶
Combining morphological and electrophysiological features raises accuracy slightly, to 69% for human and 60% for mouse neurons.
The method of edfig6-classifier-human-ephys, as the updated criterion says, on the homologous cells of each species with all 18 electrophysiological features and a reconstruction, with the 18 and the 60 morphological features side by side. The main test uses the code's tables, as the criterion names them (72 human and 50 mouse cells); as a variant, the human electrophysiological features are those computed here from the dandiset (reading M2 of the link). Each is run on 250 splits, not 1000, to keep the notebook within 30 minutes; the standard error of the mean is printed.
t = time.time()
mf_h = morph_h.set_index("specimen_id")[MF]
hom_code = tab.loc[tab.index.isin(etab.index)].assign(tt=lambda x: x.SeuratMapping.str.split().str[-1])
hom_code = hom_code[hom_code.tt.isin(HOM)][["tt"]].join(etab[F]).join(mf_h, how="inner")
mo_me = mo[["tt"] + F].join(morph_m.set_index("specimen_id")[MF], how="inner")
hom_here = hom[hom.specimen_id.isin(mf_h.index)].set_index("specimen_id")[["tt"] + F].join(mf_h, how="inner")
me = {}
for name, d, n in [("human, code's tables", hom_code, 250), ("mouse, code's tables", mo_me, 250),
("variant: human, features computed here", hom_here, 100)]:
dd = d[d[F].notna().all(axis=1)]
print(f"{name}: {len(dd)} cells {dd.tt.value_counts().to_dict()}, missing morphological values "
f"{int(dd[MF].isna().sum().sum())}")
acc, _ = rf_accuracy(d, "edfig6-classifier-morphoelectric-" + name, n_splits=n, feats=F + MF)
acc_e, _ = rf_accuracy(d, "edfig6-classifier-morphoelectric-ephys-" + name, n_splits=100)
me[name] = acc.mean()
print(f" combined: mean accuracy over {n} splits {acc.mean():.4f} (SE {acc.std() / np.sqrt(n):.4f}, SD {acc.std():.4f}); "
f"electrophysiology alone on the same cells, 100 splits, {acc_e.mean():.4f}; largest class {dd.tt.value_counts().max() / len(dd):.3f}")
print({k: round(v, 3) for k, v in me.items()}, "| expected human 0.69 +/- 0.069, mouse 0.60 +/- 0.06")
print(f"{(time.time() - t) / 60:.1f} min")
human, code's tables: 72 cells {'FREM3': 42, 'LTK': 20, 'GLP2R': 10}, missing morphological values 0
combined: mean accuracy over 250 splits 0.7200 (SE 0.0052, SD 0.0829); electrophysiology alone on the same cells, 100 splits, 0.6791; largest class 0.583
mouse, code's tables: 50 cells {'Agmat': 25, 'Rrad': 19, 'Adamts2': 6}, missing morphological values 0
combined: mean accuracy over 250 splits 0.5816 (SE 0.0066, SD 0.1048); electrophysiology alone on the same cells, 100 splits, 0.5273; largest class 0.500
variant: human, features computed here: 70 cells {'FREM3': 42, 'LTK': 19, 'GLP2R': 9}, missing morphological values 0
combined: mean accuracy over 100 splits 0.7152 (SE 0.0095, SD 0.0945); electrophysiology alone on the same cells, 100 splits, 0.6714; largest class 0.600
{"human, code's tables": np.float64(0.72), "mouse, code's tables": np.float64(0.582), 'variant: human, features computed here': np.float64(0.715)} | expected human 0.69 +/- 0.069, mouse 0.60 +/- 0.06
5.1 min
Result: reproduced. On the code's tables, the 72 human cells (42 FREM3, 20 LTK, 10 GLP2R) give a mean accuracy of 0.720 over 250 splits (SE 0.005), within 0.69 +/- 0.069, and the 50 mouse cells give 0.582 (SE 0.007), within 0.60 +/- 0.06. On the same cells the electrophysiological features alone give 0.679 (human) and 0.527 (mouse) over 100 splits, so the combined features raise accuracy, as stated. With the human features computed here (70 cells), the combined accuracy is 0.715 over 100 splits.
fig5d-frem3-gene-depth¶
FREM3 gene expression varies with soma depth; 790 genes correlate with depth at FDR below 0.05.
print("genes in the table:", len(genes_depth), "| FDR < 0.05:", int((genes_depth.p_corr < 0.05).sum()),
"(expected 790 +/- 79) | FDR < 0.01:", int((genes_depth.p_corr < 0.01).sum()))
print("p_corr range", genes_depth.p_corr.min(), "to", genes_depth.p_corr.max(), "| features", genes_depth.feature.unique())
genes in the table: 33245 | FDR < 0.05: 4417 (expected 790 +/- 79) | FDR < 0.01: 1917 p_corr range 5.8305047563545404e-21 to 0.9999902948934364 | features <StringArray> ['depth'] Length: 1, dtype: str
Result: blocked (other). The code's table gives 4417 genes at FDR below 0.05 (against 790) and 1917 below 0.01, the count the code's own notebook gives for its revision; the preprint's gene results are not public, so the claim cannot be tested on its own data.
Figure 1a-c: NeuN sections¶
A port of the code's Code6 (human) and Code7 (mouse) R scripts to Python (patchseq_l23.section_tables).
The scripts carry their printed output as comments, and the port is checked against every value
there (read from the scripts at the pinned commit, in the table below): the L2/3 thicknesses and L2
fractions of each section, the densities, the eight pooled quantiles and six largest areas of each
species, and Code7's four human/mouse ratios of mean and SD of soma area. Code7 as committed reads the
four mouse lines as L2, L4, L5 and L6 and sets 100 um = 330 pixels for every mouse section; that does
not give its printed values. Reading the lines as L1 to L4, as Code6 does for human, with case_set_1 at
100 um = 165 pixels (the scale Code7's own comment gives), gives every printed value but two of the
ratios, and is used. Both readings are printed.
The two ratios are the SD ratios. Code7 takes the human bin table from Code6, which never sets q9 to
NULL (Code7 does, for each section), so q9 grows from section to section and R's cbind repeats each
human section's 20 bins once per 20 values of q9: section k of 5, in file order, counts k + s times
in the means, where s is the number of sections' worth of q9 present when Code6 starts. Code6 run on
its own stops at q9, so some was present; how much is not known. The table shows s = 0, 1 and 2
(patchseq_l23.code6_recycled). Counting each section once, as the criteria say, is the main reading.
H = P.section_tables("human")
M = P.section_tables("mouse") # the reading that gives Code7's printed values
M_committed = P.section_tables("mouse", "as_committed")
for sp_name, tabs in [("human", H), ("mouse", M), ("mouse, Code7 as committed", M_committed)]:
for case, t in tabs.items():
c = t["cells"]
print(f"{sp_name} {case}: {t['lines']} boundary lines, {len(c)} somata, L2/3 thickness {t['l23_um']:.0f} um, "
f"L2 fraction {t['l2_fraction']:.4f}, {100 / t['um_per_px']:.0f} pixels per 100 um, "
f"scaled depth before clipping {c.scaled_unclipped.min():.2f} to {c.scaled_unclipped.max():.2f} "
f"({int((c.scaled_unclipped < -1).sum())} below -1, {int((c.scaled_unclipped > 0).sum())} above 0), "
f"area {c.area.min():.1f} to {c.area.max():.1f} um2")
dens_h, per_h = P.density_profile(H)
dens_m, per_m = P.density_profile(M)
_, per_mc = P.density_profile(M_committed)
am_c = pd.concat([v["cells"].area for v in M_committed.values()])
print(f"\nmouse, Code7 as committed: density {per_mc.mean():.1f} +/- {per_mc.std():.1f} thousand per mm3, pooled area quartiles "
f"{am_c.quantile(0.25):.1f} and {am_c.quantile(0.75):.1f} um2 (the first round of this attempt)")
human case_072: 8 boundary lines, 631 somata, L2/3 thickness 1058 um, L2 fraction -0.1790, 95 pixels per 100 um, scaled depth before clipping -1.00 to 0.01 (0 below -1, 1 above 0), area 47.6 to 640.4 um2 human case_246: 4 boundary lines, 1127 somata, L2/3 thickness 1293 um, L2 fraction -0.1995, 95 pixels per 100 um, scaled depth before clipping -0.99 to 0.01 (0 below -1, 3 above 0), area 28.8 to 886.4 um2 human case_316: 4 boundary lines, 878 somata, L2/3 thickness 1387 um, L2 fraction -0.1639, 95 pixels per 100 um, scaled depth before clipping -1.00 to 0.01 (1 below -1, 1 above 0), area 13.3 to 721.3 um2 human case_360: 4 boundary lines, 880 somata, L2/3 thickness 1073 um, L2 fraction -0.1988, 95 pixels per 100 um, scaled depth before clipping -1.00 to -0.01 (0 below -1, 0 above 0), area 22.2 to 745.7 um2 human case_732: 4 boundary lines, 904 somata, L2/3 thickness 1344 um, L2 fraction -0.1895, 95 pixels per 100 um, scaled depth before clipping -0.99 to -0.01 (0 below -1, 0 above 0), area 34.3 to 626.0 um2 mouse case_set_1: 4 boundary lines, 527 somata, L2/3 thickness 281 um, L2 fraction -0.2461, 165 pixels per 100 um, scaled depth before clipping -0.99 to -0.02 (0 below -1, 0 above 0), area 13.6 to 244.6 um2 mouse case_set_2: 4 boundary lines, 450 somata, L2/3 thickness 223 um, L2 fraction -0.2050, 330 pixels per 100 um, scaled depth before clipping -1.01 to -0.00 (2 below -1, 0 above 0), area 4.5 to 104.1 um2 mouse case_set_3: 4 boundary lines, 442 somata, L2/3 thickness 257 um, L2 fraction -0.3253, 330 pixels per 100 um, scaled depth before clipping -1.03 to -0.01 (3 below -1, 0 above 0), area 12.9 to 186.0 um2 mouse, Code7 as committed case_set_1: 4 boundary lines, 527 somata, L2/3 thickness 32 um, L2 fraction nan, 330 pixels per 100 um, scaled depth before clipping -5.88 to -1.09 (527 below -1, 0 above 0), area 3.4 to 61.2 um2 mouse, Code7 as committed case_set_2: 4 boundary lines, 450 somata, L2/3 thickness 133 um, L2 fraction nan, 330 pixels per 100 um, scaled depth before clipping -2.69 to -1.00 (450 below -1, 0 above 0), area 4.5 to 104.1 um2 mouse, Code7 as committed case_set_3: 4 boundary lines, 442 somata, L2/3 thickness 90 um, L2 fraction nan, 330 pixels per 100 um, scaled depth before clipping -4.08 to -1.03 (442 below -1, 0 above 0), area 12.9 to 186.0 um2 mouse, Code7 as committed: density 349.8 +/- 338.5 thousand per mm3, pooled area quartiles 24.4 and 61.0 um2 (the first round of this attempt)
# The port against every value Code6 and Code7 print (read from the scripts' comments at the pinned commit)
pv = P.code_printed_values()
ah_all = pd.concat([v["cells"].area for v in H.values()])
am_all = pd.concat([v["cells"].area for v in M.values()])
port = {"thickness_human": [round(v["l23_um"]) for v in H.values()],
"thickness_mouse": [round(v["l23_um"]) for v in M.values()],
"l2_fraction_human": [round(v["l2_fraction"], 7) for v in H.values()],
"l2_fraction_mouse": [round(v["l2_fraction"], 7) for v in M.values()],
"density_human": [float(f"{per_h.mean():.3g}"), float(f"{per_h.std():.3g}")],
"density_mouse": [float(f"{per_m.mean():.3g}"), float(f"{per_m.std():.3g}")],
"quantiles_human": ah_all.quantile(P.QUANTILE_P).round(5).tolist(),
"quantiles_mouse": am_all.quantile(P.QUANTILE_P).round(6).tolist(),
"largest_human": sorted(ah_all.round(4), reverse=True)[:6],
"largest_mouse": sorted(am_all.round(4), reverse=True)[:6]}
def species_ratios(dh):
"""Code7's four human/mouse ratios from a human bin table and the mouse one."""
t = pd.concat([dh.assign(species="human"), dens_m.assign(species="mouse")])
l2_bins, l3_bins = t.centre >= -0.15, (t.centre >= -0.95) & (t.centre < -0.7)
out = {}
for col, name in [("area", "area"), ("het", "sd")]:
for sel, where in [(l2_bins, "l2"), (l3_bins, "deep_l3")]:
g = t[sel].groupby("species")[col].mean()
out[f"{name}_{where}"] = g.human / g.mouse
return out
r_plain = species_ratios(dens_h)
# Code6's q9 is never reset, so cbind repeats section k's bins k + start times (start: sections' worth of q9
# already present when Code6 runs, unknown; Code6 alone stops without one)
r_code6 = {st: species_ratios(P.code6_recycled(dens_h, list(H), start=st)) for st in (0, 1, 2)}
rows = []
for k, v in port.items():
rows.append(dict(value=k, printed=pv[k], port=v, equal=bool(np.allclose(pv[k], v, rtol=0, atol=1e-4 * max(1, np.abs(pv[k]).max())))))
for k in ["area_l2", "area_deep_l3", "sd_l2", "sd_deep_l3"]:
rows.append(dict(value=k + " (each section once)", printed=pv[k], port=round(r_plain[k], 3),
equal=float(f"{r_plain[k]:.2g}") == pv[k]))
for st, r in r_code6.items():
rows.append(dict(value=k + f" (Code6's repeated rows, start {st})", printed=pv[k], port=round(r[k], 3),
equal=float(f"{r[k]:.2g}") == pv[k]))
with pd.option_context("display.max_colwidth", 200, "display.width", 250):
print(pd.DataFrame(rows).to_string(index=False))
print("\nratios printed by Code7 matched, of 4: each section once", sum(float(f"{r_plain[k]:.2g}") == pv[k] for k in r_plain),
"|", {f"start {st}": sum(float(f"{r[k]:.2g}") == pv[k] for k in r) for st, r in r_code6.items()})
print("ratios are compared at two significant figures, as Code7 prints them; the other values at the precision printed")
value printed port equal
thickness_human [1058.0, 1293.0, 1387.0, 1073.0, 1344.0] [1058, 1293, 1387, 1073, 1344] True
thickness_mouse [281.0, 223.0, 257.0] [281, 223, 257] True
l2_fraction_human [-0.178992, -0.199479, -0.163931, -0.198835, -0.18955] [-0.178992, -0.199479, -0.163931, -0.198835, -0.18955] True
l2_fraction_mouse [-0.246144, -0.204973, -0.325279] [-0.246144, -0.204973, -0.325279] True
density_human [27.7, 4.46] [27.7, 4.46] True
density_mouse [165.0, 24.9] [165.0, 24.9] True
quantiles_human [13.2964, 62.04986, 107.47922, 168.42105, 252.63158, 343.4903, 542.30471, 886.42659] [13.2964, 62.04986, 107.47922, 168.42105, 252.63158, 343.4903, 542.30471, 886.42659] True
quantiles_mouse [4.499541, 18.999082, 44.719927, 66.115702, 96.464646, 130.394858, 178.681359, 244.628099] [4.499541, 18.999082, 44.719927, 66.115702, 96.464646, 130.394858, 178.681359, 244.628099] True
largest_human [886.4266, 885.3186, 824.3767, 787.8116, 745.7064, 722.4377] [886.4266, 885.3186, 824.3767, 787.8116, 745.7064, 722.4377] True
largest_mouse [244.6281, 216.7126, 214.1414, 210.4683, 195.4086, 194.3067] [244.6281, 216.7126, 214.1414, 210.4683, 195.4086, 194.3067] True
area_l2 (each section once) 2.1 2.074 True
area_l2 (Code6's repeated rows, start 0) 2.1 2.141 True
area_l2 (Code6's repeated rows, start 1) 2.1 2.124 True
area_l2 (Code6's repeated rows, start 2) 2.1 2.114 True
area_deep_l3 (each section once) 3.0 3.026 True
area_deep_l3 (Code6's repeated rows, start 0) 3.0 2.991 True
area_deep_l3 (Code6's repeated rows, start 1) 3.0 3.0 True
area_deep_l3 (Code6's repeated rows, start 2) 3.0 3.005 True
sd_l2 (each section once) 2.4 2.331 False
sd_l2 (Code6's repeated rows, start 0) 2.4 2.453 False
sd_l2 (Code6's repeated rows, start 1) 2.4 2.422 True
sd_l2 (Code6's repeated rows, start 2) 2.4 2.404 True
sd_deep_l3 (each section once) 4.0 3.943 False
sd_deep_l3 (Code6's repeated rows, start 0) 4.0 4.02 True
sd_deep_l3 (Code6's repeated rows, start 1) 4.0 4.001 True
sd_deep_l3 (Code6's repeated rows, start 2) 4.0 3.989 True
ratios printed by Code7 matched, of 4: each section once 2 | {'start 0': 3, 'start 1': 4, 'start 2': 4}
ratios are compared at two significant figures, as Code7 prints them; the other values at the precision printed
fig1a-thickness¶
l23 = pd.Series({k: v["l23_um"] for k, v in H.items()}) / 1000
print("human L2+L3 thickness per section (um):", (l23 * 1000).round(0).to_dict())
print(f"human L2+L3 thickness: {l23.mean():.3f} +/- {l23.std():.3f} mm over {len(l23)} donors (expected 1.23 +/- 0.15); "
f"within tolerance: {abs(l23.mean() - 1.23) <= 0.15}")
print("mouse: the sections carry", sorted(set(v["lines"] for v in M.values())),
"lines, the deepest the L3/L4 border, with no white matter line, so the whole cortex (1.06 mm) is not tested; "
"mouse L2/3 thickness, reported only (Code7 prints 281, 223 and 257):", {k: round(v["l23_um"]) for k, v in M.items()}, "um")
human L2+L3 thickness per section (um): {'case_072': 1058.0, 'case_246': 1293.0, 'case_316': 1387.0, 'case_360': 1073.0, 'case_732': 1344.0}
human L2+L3 thickness: 1.231 +/- 0.155 mm over 5 donors (expected 1.23 +/- 0.15); within tolerance: True
mouse: the sections carry [4] lines, the deepest the L3/L4 border, with no white matter line, so the whole cortex (1.06 mm) is not tested; mouse L2/3 thickness, reported only (Code7 prints 281, 223 and 257): {'case_set_1': 281, 'case_set_2': 223, 'case_set_3': 257} um
Result: reproduced, for the human value; the mouse value is untested. The human L2 plus L3 thickness is 1.231 +/- 0.155 mm over 5 sections, within 1.23 +/- 0.15. The mouse sections end at the L3/L4 border, with no white matter line, so the thickness of the whole mouse cortex (1.06 mm) and the ratio of 1.16 are not tested, as the criterion says. The mouse L2/3 thickness, reported only, is 281, 223 and 257 um, the values Code7 prints.
fig1b-density¶
print(f"human: {per_h.mean():.2f} +/- {per_h.std():.2f} thousand cells/mm3 (expected 27.7 +/- 4.5); per section {per_h.round(1).to_dict()}")
print(f"mouse: {per_m.mean():.2f} +/- {per_m.std():.2f} thousand cells/mm3 (expected 165 +/- 24.9); per section {per_m.round(1).to_dict()}")
prof = pd.concat([dens_h.assign(species="human"), dens_m.assign(species="mouse")])
prof = prof[(prof.bin > 0) & (prof.bin < 19)] # first and last bins dropped, as the code
pm = prof.groupby(["species", "centre"]).dens.mean().unstack(0).sort_index(ascending=False)
print("\nmean density by bin (0 = L1/L2 border, -1 = L3/L4 border), first and last bins dropped:")
print(pm.round(3).to_string())
hp = pm.human
print(f"human: highest at scaled depth {hp.idxmax():.3f} ({hp.max():.3f}), lowest at {hp.idxmin():.3f} ({hp.min():.3f}); "
f"ratio {hp.min() / hp.max():.2f}; mouse ratio of lowest to highest {pm.mouse.min() / pm.mouse.max():.2f}")
mp_ = pm.mouse
print(f"mouse: lowest bin over highest {mp_.min() / mp_.max():.2f}, coefficient of variation over bins {mp_.std() / mp_.mean():.3f} "
f"(human {hp.std() / hp.mean():.3f})")
human: 27.70 +/- 4.46 thousand cells/mm3 (expected 27.7 +/- 4.5); per section {'case_072': 22.8, 'case_246': 33.3, 'case_316': 24.9, 'case_360': 31.3, 'case_732': 26.1}
mouse: 164.74 +/- 24.91 thousand cells/mm3 (expected 165 +/- 24.9); per section {'case_set_1': 185.0, 'case_set_2': 172.3, 'case_set_3': 136.9}
mean density by bin (0 = L1/L2 border, -1 = L3/L4 border), first and last bins dropped:
species human mouse
centre
-0.075 1.742 0.916
-0.125 1.543 1.074
-0.175 1.267 1.041
-0.225 1.267 0.925
-0.275 1.081 1.239
-0.325 0.986 1.069
-0.375 0.949 1.042
-0.425 0.820 1.100
-0.475 0.813 1.070
-0.525 0.867 0.938
-0.575 0.745 0.962
-0.625 0.758 0.956
-0.675 0.798 1.001
-0.725 0.790 0.922
-0.775 0.834 1.053
-0.825 0.874 0.997
-0.875 0.921 1.007
-0.925 0.917 1.093
human: highest at scaled depth -0.075 (1.742), lowest at -0.575 (0.745); ratio 0.43; mouse ratio of lowest to highest 0.74
mouse: lowest bin over highest 0.74, coefficient of variation over bins 0.080 (human 0.282)
Result: reproduced. The human density is 27.70 +/- 4.46 thousand cells/mm3 and the mouse density 164.74 +/- 24.91, both within tolerance and as Code7 prints them. Human density is highest just below L1 (1.742) and lowest at scaled depth -0.575 (0.745), a ratio of 0.43, about half. Mouse density varies less with depth: its lowest bin is 0.74 of its highest, and its coefficient of variation over bins is 0.080, against 0.282 in human. Code7 as committed (lines read as L2, L4, L5 and L6, and 330 pixels per 100 um in every mouse section) gives a mouse density of 349.8 +/- 338.5, the first round's value, and puts every mouse soma below the deepest line it uses.
fig1c-soma-area and fig1c-soma-variation¶
ah = pd.concat([v["cells"].area for v in H.values()])
am = pd.concat([v["cells"].area for v in M.values()])
q = pd.DataFrame({"human": ah.quantile([0.25, 0.75]), "mouse": am.quantile([0.25, 0.75])})
print("pooled quartiles over all somata of a species (um2), as judged:\n", q.round(1).to_string(), f"\nlargest human soma {ah.max():.1f} um2; n human {len(ah)}, mouse {len(am)}")
qs = [0, 0.05, 0.25, 0.5, 0.75, 0.9, 0.99, 1]
print("pooled quantiles", qs, "\n human", ah.quantile(qs).round(2).tolist(), "\n mouse", am.quantile(qs).round(2).tolist())
per_case = pd.DataFrame({f"{sp_}:{k}": v["cells"].area.quantile([0.25, 0.75]) for sp_, tabs in [("human", H), ("mouse", M)] for k, v in tabs.items()}).T
print("\nper section, reported only:\n", per_case.round(1).to_string())
exp_q = {("human", 0.25): (107, 10.7), ("human", 0.75): (253, 25.3), ("mouse", 0.25): (44, 4.4), ("mouse", 0.75): (96, 9.6)}
print("within tolerance:", {f"{s_} {qq}": bool(abs(q.loc[qq, s_] - v) <= tol) for (s_, qq), (v, tol) in exp_q.items()},
"| largest human soma above 850 um2:", ah.max() > 850)
print("mean of section quartiles: human", per_case.filter(like="human", axis=0).mean().round(1).to_dict(),
"mouse", per_case.filter(like="mouse", axis=0).mean().round(1).to_dict())
pa = prof.groupby(["species", "centre"]).area.mean().unstack(0).sort_index(ascending=False)
print("\nmean area by bin (first and last dropped):\n", pa.round(1).to_string())
print(f"deepest kept bin over shallowest: human {pa.human.iloc[-1] / pa.human.iloc[0]:.2f}, mouse {pa.mouse.iloc[-1] / pa.mouse.iloc[0]:.2f}")
pooled quartiles over all somata of a species (um2), as judged:
human mouse
0.25 107.5 44.7
0.75 252.6 96.5
largest human soma 886.4 um2; n human 4420, mouse 1419
pooled quantiles [0, 0.05, 0.25, 0.5, 0.75, 0.9, 0.99, 1]
human [13.3, 62.05, 107.48, 168.42, 252.63, 343.49, 542.3, 886.43]
mouse [4.5, 19.0, 44.72, 66.12, 96.46, 130.39, 178.68, 244.63]
per section, reported only:
0.25 0.75
human:case_072 131.9 263.7
human:case_246 105.3 270.4
human:case_316 88.6 202.8
human:case_360 110.8 255.4
human:case_732 117.5 278.1
mouse:case_set_1 75.8 129.5
mouse:case_set_2 27.0 61.9
mouse:case_set_3 47.5 84.0
within tolerance: {'human 0.25': True, 'human 0.75': True, 'mouse 0.25': True, 'mouse 0.75': True} | largest human soma above 850 um2: True
mean of section quartiles: human {0.25: 110.8, 0.75: 254.1} mouse {0.25: 50.1, 0.75: 91.8}
mean area by bin (first and last dropped):
species human mouse
centre
-0.075 127.0 59.3
-0.125 138.6 65.7
-0.175 156.8 62.2
-0.225 172.8 69.2
-0.275 182.2 65.7
-0.325 201.7 68.8
-0.375 207.8 76.9
-0.425 221.0 67.9
-0.475 208.4 77.7
-0.525 223.0 74.1
-0.575 235.0 71.3
-0.625 229.7 72.6
-0.675 238.6 76.3
-0.725 245.4 73.8
-0.775 242.4 80.3
-0.825 237.6 81.5
-0.875 224.4 76.1
-0.925 218.6 74.5
deepest kept bin over shallowest: human 1.72, mouse 1.26
Result: reproduced. Pooled over all somata of a species, as the criterion says, the human quartiles are 107.5 and 252.6 um2 and the mouse quartiles 44.7 and 96.5 um2, all within tolerance; all eight pooled quantiles of each species and the six largest somata equal those Code7 prints (table above), and the largest human soma is 886.4 um2, above 850. Per section, reported only, the means of section quartiles are 110.8 and 254.1 (human) and 50.1 and 91.8 (mouse). In human the mean area rises from 127.0 um2 in the shallowest kept bin to 245.4 at its peak; in mouse it ranges from 59.3 to 81.5 um2, and the deepest kept bin is 1.26 times the shallowest.
allb = pd.concat([dens_h.assign(species="human"), dens_m.assign(species="mouse")])
for name, sel in [("(D1, judged) Code7's bins, centres -0.95 to -0.7", (allb.centre >= -0.95) & (allb.centre < -0.7)),
("(D2, variant) centres deeper than -0.575, deepest bin dropped", (allb.centre < -0.575) & (allb.bin > 0))]:
print(name, "| bin centres", sorted(allb[sel].centre.round(3).unique()))
het = allb[sel].groupby("species").het.mean()
nm = int(allb[sel & (allb.species == "mouse")].n.sum())
nh = int(allb[sel & (allb.species == "human")].n.sum())
ratio = het.human / het.mouse if np.isfinite(het.get("mouse", np.nan)) else np.nan
print(f" SD human {het.human:.1f} um2 ({nh} somata), mouse {het.get('mouse', np.nan):.1f} um2 ({nm} somata); "
f"ratio {ratio:.2f} (expected 4 +/- 0.4)")
print("bins: 0 is the deepest (centre -0.975)")
# variant: the areas binned as the density is (right-closed), not as the scripts bin them (left-closed)
dh_r, _ = P.density_profile(H, area_bins="right")
dm_r, _ = P.density_profile(M, area_bins="right")
allr = pd.concat([dh_r.assign(species="human"), dm_r.assign(species="mouse")])
het_r = allr[(allr.centre >= -0.95) & (allr.centre < -0.7)].groupby("species").het.mean()
print(f"variant, right-closed area bins: D1 ratio {het_r.human / het_r.mouse:.2f}; somata at scaled depth exactly 0 "
f"(in no left-closed area bin): human {sum(int((v['cells'].scaled_depth == 0).sum()) for v in H.values())}, "
f"mouse {sum(int((v['cells'].scaled_depth == 0).sum()) for v in M.values())}")
sd_m = pd.concat([v["cells"].scaled_depth for v in M.values()])
print(f"mouse somata: {len(sd_m)}, scaled depth {sd_m.min():.2f} to {sd_m.max():.2f}, {int((sd_m == -1).sum())} clipped to -1")
het2 = allb[allb.centre >= -0.15].groupby("species").het.mean()
print(f"for reference, L2 bins (centres from -0.15): ratio {het2.human / het2.mouse:.2f}")
(D1, judged) Code7's bins, centres -0.95 to -0.7 | bin centres [np.float64(-0.925), np.float64(-0.875), np.float64(-0.825), np.float64(-0.775), np.float64(-0.725)] SD human 117.6 um2 (948 somata), mouse 29.8 um2 (357 somata); ratio 3.94 (expected 4 +/- 0.4) (D2, variant) centres deeper than -0.575, deepest bin dropped | bin centres [np.float64(-0.925), np.float64(-0.875), np.float64(-0.825), np.float64(-0.775), np.float64(-0.725), np.float64(-0.675), np.float64(-0.625)] SD human 115.4 um2 (1289 somata), mouse 30.1 um2 (496 somata); ratio 3.83 (expected 4 +/- 0.4) bins: 0 is the deepest (centre -0.975) variant, right-closed area bins: D1 ratio 3.94; somata at scaled depth exactly 0 (in no left-closed area bin): human 5, mouse 0 mouse somata: 1419, scaled depth -1.00 to -0.00, 5 clipped to -1 for reference, L2 bins (centres from -0.15): ratio 2.33
Result: reproduced. With deep L3 as Code7's five bins (D1, as the criterion says), the mean SD of soma area is 117.6 um2 in human (948 somata) and 29.8 um2 in mouse (357 somata), a ratio of 3.94, within 4 +/- 0.4. The variant D2 gives 3.83, and binning the areas as the density is binned gives 3.94. Five human somata sit at scaled depth exactly 0 and fall in no area bin, as in the scripts; none is in deep L3. Code7 prints 4.0 for this ratio, and the port, counting each section once as the criterion says, gives 3.94, which rounds to 3.9. With Code6's repeated rows (table above) the ratio is 4.02, 4.00 and 3.99 for s = 0, 1 and 2, and with s = 1 or 2 the port gives all four ratios Code7 prints. The ratio is within tolerance under each of these.
Summary¶
A failure to reproduce here may be a failure of this attempt, not of the paper: see the reasoning and the differences from the paper's method.
| Claim | Data | Outcome |
|---|---|---|
| features-and-labels-link | with labels | reproduced under M2 (M1 links no cell) |
| cohort-cells | with labels | not reproduced (318 cells, 280 with features) |
| cohort-donors | with labels | not reproduced (56 donors) |
| cohort-type-counts | with labels | not reproduced |
| fig3d-depth-by-type | with labels | partially reproduced |
| fig4e-human-ephys-anova | with labels | partially reproduced |
| fig4-glp2r-sag | with labels | reproduced |
| edfig6-classifier-human-ephys | with labels | reproduced |
| fig5c-frem3-ephys-depth | with labels | partially reproduced |
| fig6-deep-ephys-anova | with labels | reproduced |
| fig6c-carm1p1-upstroke-rin | with labels | blocked, methods underspecified |
| fig6c-col22a1-rin-fi-sag | with labels | reproduced |
| fig4e-mouse-ephys-anova | with inputs | reproduced |
| edtable1-species-ephys | with inputs | reproduced |
| edfig6-classifier-mouse-ephys | with inputs | reproduced |
| fig2ef-pathology-ephys | with inputs | partially reproduced |
| fig2d-pathology-scores | elsewhere | reproduced |
| edfig1-marker-correlation | elsewhere | reproduced |
| fig4f-morph-anova | elsewhere | reproduced |
| fig5b-frem3-morph-depth | elsewhere | reproduced |
| fig6-deep-morph-anova | elsewhere | reproduced |
| fig1a-thickness | elsewhere | reproduced (human value; mouse value untested) |
| fig1b-density | elsewhere | reproduced |
| fig1c-soma-area | elsewhere | reproduced |
| fig1c-soma-variation | elsewhere | reproduced |
| fig5d-frem3-gene-depth | elsewhere | blocked (revision's table) |
| edfig6-classifier-morphoelectric | elsewhere | reproduced |
| fig6a-deep-dendrites | elsewhere | blocked, methods underspecified (readings differ) |
| fig1f-frem3-heterogeneity, fig1g-deep-types-de-genes, fig3a-platform-correlation, fig6e-deep-de-genes, fig6f-smi32 | elsewhere | blocked (data not pinned or not public) |
How the analysis differs from the paper's: The files carry no SpecimenID; cells were matched to the code's table through the session id (the next SpecimenID of the same donor, reading M2 of the link), which the features confirm for 261 of the 283 cells with features in the code under the Methods' sweep QC (a match on features alone picks the same cell for 261 of 261) and for 282 of them under IPFX's sweep QC alone (282 of 282), and the sample dates and tube order support for the 35 cells without features in the code; one of the 283 gives features under neither QC, and its date matches; under M1, a SpecimenID stored in the files, no cell links. Features were computed with IPFX 2.1.2 (the paper gives no version) and read from its output as the code's feature names imply. The sweep QC is the Methods', with the bias current and bridge balance limits that IPFX 2.1.2 does not apply added, and the input resistance of IPFX's cell QC for the 15% limit, a choice the Methods do not fix; IPFX's sweep QC alone matches the code's table more closely. No cell QC is applied, as the claims file asks. The analysis cells are every file whose matched cell has the feature, which adds 19 cells to the code's 283 and loses 22 of them; the section on cell sets gives every electrophysiology outcome on the 283 alone, with cell QC and with IPFX's sweep QC. Labels, pathology scores and the mouse features come from the code's tables, which are from the paper's revision. Code6 and Code7 were ported to Python; for mouse, the port reads the boundary lines and pixel scale in the way that gives Code7's printed values, not as Code7's code is committed. The morpho-electric classifier runs 250 splits, not 1000, to keep the notebook within 30 minutes.
What was found about the dataset: It holds 318 recordings from 56 donors: every one of the 283 cells with features in the paper's code, and 35 more of the code's 385 cells; 67 cells of the table are not in it. The files carry no SpecimenID, t-type, depth or region, so no claim of the paper can be tested from the dandiset alone, and the archive's description does not say which cells were deposited or why. Donor H18.03.318 is female in the files and male in the paper's donor table, and donor H18.06.005 is 56 years old in the files and 57 in the table. The recordings themselves are consistent with the paper's code: spike times computed here equal those stored in the files, and the features equal the code's values in most cells. The code's adaptation is the mean over all spiking long squares and its initial rate and tau come from the hero sweep and long squares, where the Methods describe adaptation at about 50 pA above rheobase, initial rate at rheobase and tau from short pulses. In the code repository, Code7 as committed does not give the values its comments print; the reading that does takes the mouse lines as Code6 takes the human ones and case_set_1 at 165 pixels per 100 um. Code6 never resets q9, so the human bin table Code7 uses repeats each section's bins a different number of times; with that repetition the port gives Code7's printed SD ratios (4.0 for deep L3, against 3.94 with each section once).
print(f"notebook ran in {(time.time() - T0) / 60:.1f} min")
notebook ran in 30.1 min