Rozsa et al. (2023) on DANDI:000341, part 3: in vivo recordings¶
Paper: Rozsa, Toth, Olah, Baka, Lakovics, Barzo and Tamas (2023), Sci. Adv. 9, eade4511,
doi:10.1126/sciadv.ade4511. Claims file: claims/rozsa-2023.yaml, written from the version of
record (Europe PMC full text) and its supplement.
Dataset: DANDI:000341, version 0.241220.1312 (doi:10.48324/dandi.000341/0.241220.1312), the only published version; the paper cites the dandiset without a version.
This notebook covers the folder In_vivo (259 files, 383 GB): whole-cell recordings of layer 1
interneurons in mice, most with a layer 5 LFP. Each file is taken as one cell (checked for
repeats below). It was added after the first verification round, which found that the earlier
block of these claims as too large was not justified.
The dandiset carries no AP labels, so AIS-APs and RA-APs can only be separated by reading (b) of
the claims file's header, a two-component Gaussian mixture on threshold and pre-AP slope fitted to
all in vivo APs pooled, RA-APs being the component with the lower threshold (raf.gmm_classes).
Its components are checked against the paper's description of RA-APs (lower threshold and lower
slope) before any claim is judged.
| Claim | Here |
|---|---|
| fig4b-invivo-ra-proportion | tested |
| fig4i-invivo-frequencies | tested |
| fig4g-invivo-ra-share | tested |
| fig4f-invivo-pre-ap-fluctuation | tested |
| fig4j-invivo-ais-phase-coupling | tested |
| fig4j-invivo-ra-no-phase | tested |
| fig4-invivo-up-down-balance | tested |
| figs4i-ais-ra-frequency-correlation | tested |
| figs5-not-genotype-or-anesthesia | genotype tested; the condition is not in the files |
import zlib, time, resource, collections
import numpy as np
import pandas as pd
from scipy import stats, signal
import matplotlib.pyplot as plt
import raf
%matplotlib inline
pd.set_option("display.width", 200)
pd.set_option("display.max_columns", 30)
PAPER = "rozsa-2023"
def seed(claim):
return zlib.crc32(f"{PAPER}/{claim}".encode())
T0 = time.time()
assets = raf.list_assets()
iv_assets = [a for a in assets if a["path"].startswith("In_vivo/")]
print(f"In_vivo: {len(iv_assets)} files, {sum(a['size'] for a in iv_assets) / 1e9:.0f} GB")
res = raf.process_group(iv_assets, keep=("LFP",), workers=4)
print(f"read in {(time.time() - T0) / 60:.1f} min; peak memory "
f"{resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.1f} GB")
In_vivo: 259 files, 383 GB
read in 39.3 min; peak memory 1.2 GB
Per-cell reduction¶
APs (main rule, peak above 0 mV; artefacts with a threshold outside -80 to -10 mV or a peak above 100 mV left out) of the Vm sweeps without a current step; the recording duration of a cell is the summed length of those sweeps. Steady holding current is allowed (the paper's Figure S5F shows "injected holding currents during recordings"); APs with a positive absolute current at threshold are left out in a variant.
def genotype(m):
d = str(m.get("subject_description", ""))
return d.split("Animal genotype:")[1].split(",")[0].strip() if "Animal genotype:" in d else "not given"
cells = []
for p, (m, aps, sw, lfp) in res.items():
vm = sw[sw.chan.str.startswith("Vm")]
quiet = vm[vm.nsteps == 0]
a = aps[aps.main & raf.plausible(aps) & aps.series.isin(set(quiet.series))] if len(aps) else aps
cells.append(dict(file=p.split("/")[-1], subject=m["subject_subject_id"], meta=m, genotype=genotype(m),
region=str(m.get("subject_description", "")).split("Brain region:")[-1].strip(),
age=m.get("subject_age"), aps=a.assign(file=p.split("/")[-1]) if len(a) else a,
n_main=int(aps.main.sum()) if len(aps) else 0, n_vm=len(vm), n_quiet=len(quiet),
dur_s=float((quiet.n / quiet.rate).sum()), lfp=lfp, n_lfp=len(lfp),
lfp_s=float(sum(len(x) / r for _, r, x in lfp.values())),
hold_med=float(quiet.hold.median()) if len(quiet) else np.nan,
chans=dict(collections.Counter(sw.chan)),
rates=sorted(set(vm.rate.round())),
fingerprint=(len(vm), tuple(vm.sort_values("start").vmed.round(3).head(20)))))
print(len(cells), "cells")
259 cells
Data check¶
C = pd.DataFrame([{k: v for k, v in c.items() if k in ("file", "subject", "genotype", "region", "age", "n_main", "n_vm",
"n_quiet", "dur_s", "n_lfp", "lfp_s", "hold_med")}
| {"n_aps": len(c["aps"])} for c in cells])
print(f"files {len(C)}, subjects {C.subject.nunique()}; Vm sweeps per file median {C.n_vm.median():.0f}; "
f"files with an LFP {int((C.n_lfp > 0).sum())}")
print("channels (series over all files):", dict(sum((collections.Counter(c["chans"]) for c in cells), collections.Counter())))
print("sampling rates (files):", dict(collections.Counter(r for c in cells for r in c["rates"])))
print(f"recording without steps per cell: median {C.dur_s.median():.0f} s, range {C.dur_s.min():.0f} to {C.dur_s.max():.0f} s; "
f"LFP per cell median {C.lfp_s.median():.0f} s")
print(f"holding current of the stepless sweeps (median per cell): {C.hold_med.min():.0f} to {C.hold_med.max():.0f} pA, "
f"median {C.hold_med.median():.0f}")
print(f"APs (peak > 0 mV) {C.n_main.sum()}, kept (stepless sweeps, plausible) {C.n_aps.sum()}; cells with no kept AP "
f"{int((C.n_aps == 0).sum())}")
print("genotypes (files):", dict(collections.Counter(C.genotype)))
print("regions (files):", dict(collections.Counter(C.region)))
print("ages:", dict(collections.Counter(C.age).most_common(10)))
fp = collections.defaultdict(list)
for c in cells:
fp[c["fingerprint"]].append(c["file"])
print("files with identical sweep fingerprints:", [v for v in fp.values() if len(v) > 1] or "none")
m0 = cells[0]["meta"]
print("metadata of", cells[0]["file"])
print(" general:", {k: v for k, v in m0["general"].items()})
print(" subject:", {k: v for k, v in m0.items() if k.startswith("subject_")})
print(" electrodes:", m0["electrode_descriptions"])
print(" pharmacology:", m0["pharmacology"])
words = ("anesth", "anaesth", "ketamine", "xylazine", "chloral", "isoflurane", "awake", "urethane")
hits = [c["file"] for c in cells if any(w in str(c["meta"]).lower() for w in words)]
print("files whose metadata mention anesthesia or wakefulness:", hits or "none")
print("session descriptions:", dict(collections.Counter(c["meta"]["session_description"] for c in cells)))
print("experiment descriptions:", dict(collections.Counter(str(c["meta"].get("experiment_description")) for c in cells)))
files 259, subjects 149; Vm sweeps per file median 59; files with an LFP 245
channels (series over all files): {'Vm': 29875, 'LFP_Trace': 25309, 'Moovie': 173}
sampling rates (files): {50000.0: 188, 200000.0: 14, 100000.0: 184, 40000.0: 1, 20000.0: 12, 20833.0: 4, 16667.0: 4}
recording without steps per cell: median 540 s, range 1 to 2407 s; LFP per cell median 551 s
holding current of the stepless sweeps (median per cell): -351 to 3 pA, median 0
APs (peak > 0 mV) 396281, kept (stepless sweeps, plausible) 291968; cells with no kept AP 39
genotypes (files): {'mouse': 5, 'mouse-ai9': 17, 'mouse-vGATCreXai9': 152, 'mouse-black6': 6, 'mouse-GAD-GFP': 79}
regions (files): {'motor': 85, 'somatosensory': 141, 'PPC': 33}
ages: {'P60D': 10, 'P120D': 9, 'P180D': 9, 'P80D': 9, 'P77D': 9, 'P81D': 9, 'P82D': 9, 'P63D': 8, 'P65D': 8, 'P58D': 8}
files with identical sweep fingerprints: none
metadata of sub-1704201rm_ses-1704201rm-1-5,6-1_icephys.nwb
general: {'experiment_description': 'Simultaneous L1 Whole-cell patch-clamp and L5 LFP recording in vivo', 'experimenter': ['Marton, Rozsa'], 'institution': 'ELKH-SZTE Research Group for Cortical Microcircuits; University of Szeged, Hungary', 'keywords': ['Whole-cell patch-clamp', 'LFP', 'Layer 1', 'Mouse Neocortex'], 'lab': 'Lab of Gabor Tamas', 'related_publications': ['https://doi.org/10.1101/2022.08.09.503303'], 'session_id': '1704201rm_1_5,6_1'}
subject: {'subject_age': 'P60D', 'subject_description': 'Animal genotype: mouse, Brain region: motor', 'subject_sex': 'M', 'subject_species': 'Mus musculus', 'subject_subject_id': '1704201rm'}
electrodes: {'Micropipette': 'Micropipette (3–6 MOhm) filled with intracellular solution containing biocytin and 10 μM Alexa'}
pharmacology: {}
files whose metadata mention anesthesia or wakefulness: none
session descriptions: {'In Vivo Layer 1 recording': 259}
experiment descriptions: {'Simultaneous L1 Whole-cell patch-clamp and L5 LFP recording in vivo': 259}
Clock check for the LFP: the starting times of the Vm and LFP series side by side, and the mean LFP around the AP peaks against the same average with the AP times shifted by 5 or 10 s.
for c in [c for c in cells if c["n_lfp"]][:3]:
sw = res[[p for p in res if p.endswith(c["file"])][0]][2].sort_values("start")
vm, lf = sw[sw.chan.str.startswith("Vm")], sw[sw.chan.str.startswith("LFP")]
print(c["file"][:40])
print(" Vm (start s, duration s):", [(round(a, 2), round(b, 1)) for a, b in zip(vm.start.head(6), (vm.n / vm.rate).head(6))])
print(" LFP (start s, duration s):", [(round(a, 2), round(b, 1)) for a, b in zip(lf.start.head(6), (lf.n / lf.rate).head(6))])
print(f" Vm series {len(vm)}, LFP series {len(lf)}, sharing a starting time "
f"{len(set(vm.start.round(3)) & set(lf.start.round(3)))}")
# The same count over every file with LFP series (verifier, round 2).
frac = []
for c in [c for c in cells if c["n_lfp"]]:
sw = res[[p for p in res if p.endswith(c["file"])][0]][2]
vm, lf = set(sw[sw.chan.str.startswith("Vm")].start.round(3)), set(sw[sw.chan.str.startswith("LFP")].start.round(3))
if lf:
frac.append(len(vm & lf) / len(lf))
print(f"files with LFP series {len(frac)}; LFP series sharing a starting time with a Vm series: median fraction "
f"{np.median(frac):.3f}, lowest {min(frac):.3f}, files where every one does {sum(f == 1 for f in frac)}")
def ap_triggered_lfp(c, shift=0.0, half=1.0):
a = c["aps"]
if not len(a) or not c["lfp"]:
return None, 0, np.nan
t = (a.sweep_start + a.t_peak).to_numpy() + shift
segs = []
for st, rate, x in c["lfp"].values():
h = int(half * rate)
i = np.round((t - st) * rate).astype(int)
i = i[(i - h >= 0) & (i + h < len(x))]
for k in i[:2000]:
seg = x[k - h:k + h + 1].astype(float)
segs.append(seg - seg.mean())
used = rate
if not segs:
return None, 0, np.nan
L = min(len(z) for z in segs)
return np.mean([z[:L] for z in segs], axis=0), len(segs), used
trig = []
for c in cells:
m0, n0, fs0 = ap_triggered_lfp(c)
if m0 is None or n0 < 20:
continue
c0, w0 = len(m0) // 2, int(round(0.05 * fs0))
null = [ap_triggered_lfp(c, shift=sh)[0] for sh in (-10, -5, 5, 10)]
null = [z[len(z) // 2 - w0:len(z) // 2 + w0 + 1].mean() for z in null if z is not None]
trig.append(dict(file=c["file"][:32], n_aps=n0, lfp_at_ap=m0[c0 - w0:c0 + w0 + 1].mean(),
shifted_mean=np.mean(null), shifted_sd=np.std(null)))
trig = pd.DataFrame(trig)
z = (trig.lfp_at_ap - trig.shifted_mean) / trig.shifted_sd.replace(0, np.nan)
print(f"cells with an LFP and at least 20 APs: {len(trig)}; LFP within 50 ms of the AP below its value with the AP "
f"times shifted in {int((trig.lfp_at_ap < trig.shifted_mean).sum())}; |z| > 2 in {int((z.abs() > 2).sum())}; "
f"z median {z.median():.2f}")
sub-1704241rm_ses-1704241rm-4-1,3-1_icep Vm (start s, duration s): [(0.0, 0.9), (2.02, 0.9), (4.04, 0.9), (6.05, 0.9), (8.07, 0.9), (10.09, 0.9)] LFP (start s, duration s): [(0.0, 0.9), (2.02, 0.9), (4.04, 0.9), (6.05, 0.9), (8.07, 0.9), (10.09, 0.9)] Vm series 53, LFP series 53, sharing a starting time 53 sub-1705151rm_ses-1705151rm-1-11-1_iceph Vm (start s, duration s): [(0.0, 0.9), (2.02, 0.9), (4.03, 0.9), (6.07, 0.9), (8.11, 0.9), (10.13, 0.9)] LFP (start s, duration s): [(0.0, 0.9), (2.02, 0.9), (4.03, 0.9), (6.07, 0.9), (8.11, 0.9), (10.13, 0.9)] Vm series 43, LFP series 44, sharing a starting time 43 sub-1705151rm_ses-1705151rm-4-1-1_icephy Vm (start s, duration s): [(0.0, 0.9), (2.02, 0.9), (4.04, 0.9), (6.05, 0.9), (8.07, 0.9), (10.09, 0.9)] LFP (start s, duration s): [(0.0, 0.9), (2.02, 0.9), (4.04, 0.9), (6.05, 0.9), (8.07, 0.9), (10.09, 0.9)] Vm series 26, LFP series 26, sharing a starting time 26
files with LFP series 245; LFP series sharing a starting time with a Vm series: median fraction 1.000, lowest 0.000, files where every one does 135
cells with an LFP and at least 20 APs: 167; LFP within 50 ms of the AP below its value with the AP times shifted in 146; |z| > 2 in 143; z median -10.42
Reading (b): the mixture on all kept in vivo APs pooled. The component means, SDs and weights are printed, with whether the RA component (lower threshold) also has the lower slope, as the paper describes RA-APs.
A = pd.concat([c["aps"] for c in cells if len(c["aps"])], ignore_index=True)
sd0 = seed("fig4b-invivo-ra-proportion")
A["ra"], GM = raf.gmm_classes(A, sd0)
A["steady"] = A.i_abs > 5
print("mixture components:", {k: (round(v, 3) if isinstance(v, float) else v) for k, v in GM.items()})
print("RA component size under seeds +0, +1000 to +4000:", raf.gmm_seed_range(A, sd0))
print(f"APs {len(A)}, RA {int(A.ra.sum())} ({A.ra.mean() * 100:.1f}%); under a positive holding current "
f"{int(A.steady.sum())}; without a stimulus series {int(A.i_abs.isna().sum())}")
print(A.groupby("ra")[["thr", "slope", "sd_thr", "sd_peak"]].median().round(2))
fig, ax = plt.subplots(figsize=(5, 4))
ax.hexbin(A.thr, A.slope.clip(-5, 15), gridsize=70, bins="log", extent=(-80, -10, -5, 15))
ax.plot([GM["thr_ra"], GM["thr_ais"]], [GM["slope_ra"], GM["slope_ais"]], "r+", ms=14, mew=2)
ax.set(xlabel="threshold (mV)", ylabel="pre-AP slope (mV/ms), clipped to -5 to 15",
title="in vivo APs; + component means")
plt.show()
print(f"slopes outside -5 to 15 mV/ms: {int((~A.slope.between(-5, 15)).sum())}")
per = []
for c in cells:
a = A[A.file == c["file"]]
per.append(dict(file=c["file"], subject=c["subject"], genotype=c["genotype"], dur_s=c["dur_s"],
n_ais=int((~a.ra).sum()), n_ra=int(a.ra.sum()),
n_ra_nosteady=int((a.ra & ~a.steady).sum()), n_ais_nosteady=int((~a.ra & ~a.steady).sum())))
P = pd.DataFrame(per)
P["f_ais"] = P.n_ais / P.dur_s.where(P.dur_s > 0)
P["f_ra"] = P.n_ra / P.dur_s.where(P.dur_s > 0)
P["n_all"] = P.n_ais + P.n_ra
print(P.describe().round(3))
mixture components: {'n': 291968, 'n_ra': 21757, 'w_ra': 0.131, 'w_ais': 0.869, 'thr_ra': -46.58, 'thr_ais': -41.248, 'slope_ra': 3.252, 'slope_ais': 1.994, 'sd_thr_ra': 11.455, 'sd_thr_ais': 7.912, 'sd_slope_ra': 3.091, 'sd_slope_ais': 0.902, 'ra_slope_lower': False}
RA component size under seeds +0, +1000 to +4000: [21757, 21916, 21831, 23687, 22371]
APs 291968, RA 21757 (7.5%); under a positive holding current 2260; without a stimulus series 0
thr slope sd_thr sd_peak
ra
False -40.84 1.95 7.16 7.93
True -46.42 4.61 7.34 8.32
slopes outside -5 to 15 mV/ms: 385
dur_s n_ais n_ra n_ra_nosteady n_ais_nosteady f_ais f_ra n_all count 259.000 259.000 259.000 259.000 259.000 259.000 259.000 259.000 mean 677.415 1043.286 84.004 83.911 1034.653 1.413 0.099 1127.290 std 564.974 1885.048 211.164 211.173 1886.506 2.287 0.224 2019.601 min 0.915 0.000 0.000 0.000 0.000 0.000 0.000 0.000 25% 233.773 6.500 0.000 0.000 3.000 0.011 0.000 8.500 50% 540.316 225.000 4.000 4.000 200.000 0.356 0.010 248.000 75% 1057.383 929.500 58.500 58.000 905.000 2.105 0.086 994.500 max 2406.802 11216.000 1682.000 1682.000 11216.000 11.739 2.077 11357.000
fig4b-invivo-ra-proportion¶
In vivo, 75 of 242 (31%) mouse layer 1 interneurons fire spontaneous APs from relatively hyperpolarized potentials, identified as RA-APs.
for label, col in (("all kept APs", "n_ra"), ("APs under a positive holding current left out", "n_ra_nosteady")):
for k in (1, 2):
n = int((P[col] >= k).sum())
print(f"{label}, at least {k} RA-AP: {n} of {len(P)} cells = {n / len(P):.3f}; of the {int((P.n_all > 0).sum())} "
f"cells with any AP = {n / max(1, int((P.n_all > 0).sum())):.3f}")
print("expected 0.31 (75 of 242), tolerance 0.031")
all kept APs, at least 1 RA-AP: 193 of 259 cells = 0.745; of the 220 cells with any AP = 0.877 all kept APs, at least 2 RA-AP: 162 of 259 cells = 0.625; of the 220 cells with any AP = 0.736 APs under a positive holding current left out, at least 1 RA-AP: 193 of 259 cells = 0.745; of the 220 cells with any AP = 0.877 APs under a positive holding current left out, at least 2 RA-AP: 162 of 259 cells = 0.625; of the 220 cells with any AP = 0.736 expected 0.31 (75 of 242), tolerance 0.031
Result: blocked (methods_underspecified). The mixture's lower-threshold component has the steeper mean slope (about 3.2 against 2.0 mV/ms), the opposite of the paper's RA-APs, so its classes are not the paper's and reading (a) cannot be run. The mixture is fitted to a seeded draw of 200,000 of the 291,968 APs, and its counts differ slightly between runs, so the numbers below are rounded; the exact ones are printed above. For the record, with these classes about 0.75 of the 259 cells (0.88 of the 220 cells with any AP) have at least one RA-AP, against 0.31.
fig4i-invivo-frequencies¶
In vivo layer 1 interneurons fire sporadically, with AIS-APs at 0.65 Hz and RA-APs at 0.004 Hz, AIS-APs being more frequent.
Readings of the criterion: (i) all cells; (ii) cells with RA-APs for the RA-AP value and all cells for the AIS-AP value; (iii) cells with any APs. Mann-Whitney U test of the per-cell frequencies.
Q = P[P.dur_s > 0]
rd = {"(i) all cells": (Q.f_ais, Q.f_ra), "(ii) RA from cells with RA-APs": (Q.f_ais, Q.f_ra[Q.n_ra > 0]),
"(iii) cells with any APs": (Q.f_ais[Q.n_all > 0], Q.f_ra[Q.n_all > 0])}
for k, (fa, fr) in rd.items():
p = stats.mannwhitneyu(fa, fr).pvalue
print(f"{k}: AIS-AP median {fa.median():.4f} Hz (n={len(fa)}, SD {fa.std():.3f}), RA-AP median {fr.median():.4f} Hz "
f"(n={len(fr)}, SD {fr.std():.3f}); Mann-Whitney P = {p:.2g}; AIS higher: {fa.median() > fr.median()}")
print(f"cells without a stepless recording (left out): {int((P.dur_s == 0).sum())}")
print("expected AIS 0.65 Hz (tolerance 0.065), RA 0.004 Hz (tolerance 0.0004), P < 0.001")
(i) all cells: AIS-AP median 0.3557 Hz (n=259, SD 2.287), RA-AP median 0.0102 Hz (n=259, SD 0.224); Mann-Whitney P = 3.4e-20; AIS higher: True (ii) RA from cells with RA-APs: AIS-AP median 0.3557 Hz (n=259, SD 2.287), RA-AP median 0.0327 Hz (n=193, SD 0.251); Mann-Whitney P = 3.2e-10; AIS higher: True (iii) cells with any APs: AIS-AP median 0.5593 Hz (n=220, SD 2.397), RA-AP median 0.0231 Hz (n=220, SD 0.239); Mann-Whitney P = 2.9e-30; AIS higher: True cells without a stepless recording (left out): 0 expected AIS 0.65 Hz (tolerance 0.065), RA 0.004 Hz (tolerance 0.0004), P < 0.001
Result: blocked (methods_underspecified). The mixture's lower-threshold component has the steeper mean slope (about 3.2 against 2.0 mV/ms), the opposite of the paper's RA-APs, so its classes are not the paper's and reading (a) cannot be run. The mixture is fitted to a seeded draw of 200,000 of the 291,968 APs, and its counts differ slightly between runs, so the numbers below are rounded; the exact ones are printed above. For the record, with these classes the AIS-AP median frequency is about 0.36 Hz and the RA-AP median about 0.010 Hz over all 259 cells (Mann-Whitney P below 1e-19), about 0.56 and 0.023 Hz over the 220 cells with APs.
fig4g-invivo-ra-share¶
RA-APs make up 3.4% of all APs recorded in vivo; the RA-AP share ranges from 0 (162 cells) to 100% (6 cells), and averages 17% in the 75 cells with RAF.
share = P.n_ra / P.n_all.where(P.n_all > 0)
raf_cells = share[P.n_ra > 0]
print(f"RA-APs {P.n_ra.sum()} of {P.n_all.sum()} APs = {P.n_ra.sum() / P.n_all.sum() * 100:.2f}%")
print(f"cells with APs and no RA-AP {int(((P.n_all > 0) & (P.n_ra == 0)).sum())}; cells with no AP at all "
f"{int((P.n_all == 0).sum())}; cells with only RA-APs {int(((P.n_all > 0) & (P.n_ais == 0)).sum())}")
print(f"RA-AP share in cells with RA-APs (n={len(raf_cells)}): mean {raf_cells.mean() * 100:.1f}%, median "
f"{raf_cells.median() * 100:.1f}%, SD {raf_cells.std() * 100:.1f}%")
print("expected: 3.4% (tolerance 0.34), 162 cells without RA-APs (16.2), 6 with only RA-APs (0.6), 17% (1.7)")
RA-APs 21757 of 291968 APs = 7.45% cells with APs and no RA-AP 27; cells with no AP at all 39; cells with only RA-APs 9 RA-AP share in cells with RA-APs (n=193): mean 16.5%, median 6.9%, SD 24.4% expected: 3.4% (tolerance 0.34), 162 cells without RA-APs (16.2), 6 with only RA-APs (0.6), 17% (1.7)
Result: blocked (methods_underspecified). The mixture's lower-threshold component has the steeper mean slope (about 3.2 against 2.0 mV/ms), the opposite of the paper's RA-APs, so its classes are not the paper's and reading (a) cannot be run. The mixture is fitted to a seeded draw of 200,000 of the 291,968 APs, and its counts differ slightly between runs, so the numbers below are rounded; the exact ones are printed above. For the record, with these classes RA-APs are about 7.5% of all APs; 26 or 27 cells with APs have none and 9 have only RA-APs; the share in cells with RA-APs is about 16% on average (median about 7%).
fig4f-invivo-pre-ap-fluctuation¶
In vivo, membrane potential fluctuations (SD) 0 to 50 ms before AIS-APs are larger than before RA-APs.
As for fig3f in the slices notebook: the SD of the membrane potential in the 50 ms window ending at the threshold or at the peak (the criterion's readings), APs pooled; per-cell medians and isolated APs (no AP in the preceding 50 ms) as variants.
D = A.sort_values(["file", "series", "t_thr"]).copy()
prev = D.groupby(["file", "series"], observed=True).t_peak.shift(1)
D["isolated"] = (D.t_thr - prev).fillna(np.inf) > 0.05
for col in ("sd_thr", "sd_peak"):
for iso in (False, True):
d = D[D.isolated] if iso else D
a, b = d[~d.ra][col].dropna(), d[d.ra][col].dropna()
p = stats.mannwhitneyu(a, b).pvalue
pc = d.dropna(subset=[col]).groupby(["file", "ra"])[col].median().unstack()
pcp = stats.mannwhitneyu(pc[False].dropna(), pc[True].dropna()).pvalue if True in pc and pc[True].notna().sum() else np.nan
print(f"window to {col[3:]}{' [isolated APs]' if iso else ''}: AIS-AP median {a.median():.2f} mV (n={len(a)}), "
f"RA-AP {b.median():.2f} mV (n={len(b)}), Mann-Whitney P = {p:.2g}; per-cell medians P = {pcp:.2g}")
print("expected: AIS-AP SD higher, Mann-Whitney P < 0.001")
window to thr: AIS-AP median 7.16 mV (n=269920), RA-AP 7.34 mV (n=21712), Mann-Whitney P = 6.2e-15; per-cell medians P = 0.017 window to thr [isolated APs]: AIS-AP median 2.96 mV (n=109042), RA-AP 2.85 mV (n=9535), Mann-Whitney P = 2.2e-05; per-cell medians P = 0.086 window to peak: AIS-AP median 7.93 mV (n=269920), RA-AP 8.32 mV (n=21712), Mann-Whitney P = 4.7e-81; per-cell medians P = 0.32
window to peak [isolated APs]: AIS-AP median 4.69 mV (n=109042), RA-AP 4.81 mV (n=9535), Mann-Whitney P = 6.3e-31; per-cell medians P = 0.16 expected: AIS-AP SD higher, Mann-Whitney P < 0.001
Result: blocked (methods_underspecified). The mixture's lower-threshold component has the steeper mean slope (about 3.2 against 2.0 mV/ms), the opposite of the paper's RA-APs, so its classes are not the paper's and reading (a) cannot be run. The mixture is fitted to a seeded draw of 200,000 of the 291,968 APs, and its counts differ slightly between runs, so the numbers below are rounded; the exact ones are printed above. For the record, with these classes the SD before RA-APs is the higher one (window to threshold about 7.3 against 7.2 mV, P below 1e-14; window to peak about 8.3 against 7.9 mV).
fig4j-invivo-ais-phase-coupling, fig4j-invivo-ra-no-phase and fig4-invivo-up-down-balance¶
In vivo, AIS-APs are coupled to the trough of the slow (0.5 to 4 Hz) LFP oscillation (mean vector length 0.019, angle 330 degrees). RA-APs are not significantly coupled to any phase of the slow oscillation. AIS-APs dominate during up states and RA-APs during down states.
The Methods' phase procedure, as in the slices notebook: the 4 s LFP segment centred on each AP peak, FFT power times frequency, the AP kept when the power in 0.5 to 4 Hz over that in 0.5 to 45 Hz exceeds 0.1; the LFP band-passed 0.5 to 4 Hz (Butterworth order 2, zero phase; order 4 the variant), Hilbert phase at the AP peak shifted by 180 degrees so that the trough is 0 degrees. All cells with an LFP and all states pooled (criterion).
FS = 500.0
def ap_phases(c, aps, order=2):
out = []
for name, (st, rate, x) in c["lfp"].items():
dur = len(x) / rate
t = (aps.sweep_start + aps.t_peak).to_numpy()
sel = aps[(t >= st + 2) & (t <= st + dur - 2)]
if not len(sel):
continue
q = int(round(rate / FS))
y = signal.decimate(x.astype(float), q, ftype="fir") if q > 1 else x.astype(float)
fs = rate / q
sos = signal.butter(order, (0.5, 4.0), btype="band", fs=fs, output="sos")
ph = np.angle(signal.hilbert(signal.sosfiltfilt(sos, y)), deg=True)
for _, ap in sel.iterrows():
i = int(round((ap.sweep_start + ap.t_peak - st) * fs))
h = int(round(2 * fs))
if i - h < 0 or i + h > len(y):
continue
seg = y[i - h:i + h]
F = np.fft.rfftfreq(len(seg), 1 / fs)
Pw = np.abs(np.fft.rfft(seg - seg.mean())) ** 2 * F
ratio = Pw[(F >= 0.5) & (F <= 4)].sum() / Pw[(F >= 0.5) & (F <= 45)].sum()
out.append(dict(file=c["file"], ra=ap.ra, steady=ap.steady, ratio=ratio, phase=(ph[i] + 180) % 360))
return pd.DataFrame(out)
PH = {}
for order in (2, 4):
parts = [ap_phases(c, A[A.file == c["file"]], order) for c in cells if c["lfp"] and len(c["aps"])]
PH[order] = pd.concat([p for p in parts if len(p)])
print({o: len(v) for o, v in PH.items()}, "APs with a 4 s LFP segment, from", PH[2].file.nunique(), "cells")
def phase_report(Pd, label):
out = {}
for ra, name in ((False, "AIS-APs"), (True, "RA-APs")):
d = Pd[Pd.ra == ra]
k = d[d.ratio > 0.1]
rr, ang, p, n = raf.rayleigh(k.phase)
out[name] = (rr, ang, p, n)
print(f"{label} {name}: with LFP {len(d)} from {d.file.nunique()} cells; kept by delta ratio {n} from "
f"{k.file.nunique()} cells; vector length {rr:.3f}, angle {ang:.0f} deg, Rayleigh P = {p:.2g}")
return out
PR = {}
PR["o2"] = phase_report(PH[2], "order 2")
PR["o4"] = phase_report(PH[4], "order 4")
PR["nosteady"] = phase_report(PH[2][~PH[2].steady], "order 2, APs under a positive holding current left out")
{2: 264639, 4: 264639} APs with a 4 s LFP segment, from 205 cells
order 2 AIS-APs: with LFP 245531 from 200 cells; kept by delta ratio 224598 from 199 cells; vector length 0.431, angle 332 deg, Rayleigh P = 0
order 2 RA-APs: with LFP 19108 from 178 cells; kept by delta ratio 16985 from 173 cells; vector length 0.379, angle 323 deg, Rayleigh P = 0
order 4 AIS-APs: with LFP 245531 from 200 cells; kept by delta ratio 224598 from 199 cells; vector length 0.423, angle 332 deg, Rayleigh P = 0
order 4 RA-APs: with LFP 19108 from 178 cells; kept by delta ratio 16985 from 173 cells; vector length 0.375, angle 323 deg, Rayleigh P = 0
order 2, APs under a positive holding current left out AIS-APs: with LFP 243711 from 194 cells; kept by delta ratio 222860 from 192 cells; vector length 0.433, angle 332 deg, Rayleigh P = 0
order 2, APs under a positive holding current left out RA-APs: with LFP 19090 from 178 cells; kept by delta ratio 16967 from 173 cells; vector length 0.379, angle 323 deg, Rayleigh P = 0
rr, ang, p, n = PR["o2"]["AIS-APs"]
print(f"AIS-APs: n {n}, vector length {rr:.3f} (expected 0.019, tolerance 0.0019), angle {ang:.0f} deg "
f"(expected 330, distance {raf.circ_dist(ang, 330):.0f}, tolerance 33), Rayleigh P = {p:.2g} (expected < 0.001)")
AIS-APs: n 224598, vector length 0.431 (expected 0.019, tolerance 0.0019), angle 332 deg (expected 330, distance 2, tolerance 33), Rayleigh P = 0 (expected < 0.001)
Result: blocked (methods_underspecified). The mixture's lower-threshold component has the steeper mean slope (about 3.2 against 2.0 mV/ms), the opposite of the paper's RA-APs, so its classes are not the paper's and reading (a) cannot be run. The mixture is fitted to a seeded draw of 200,000 of the 291,968 APs, and its counts differ slightly between runs, so the numbers below are rounded; the exact ones are printed above. For the record, with these classes about 224,500 AIS-APs from 199 cells are coupled at 332 degrees (Rayleigh P printed as 0) with a vector length of about 0.43, against 0.019.
for k in ("o2", "o4", "nosteady"):
rr, ang, p, n = PR[k]["RA-APs"]
print(f"{k}: RA-APs n {n}, vector length {rr:.3f}, angle {ang:.0f} deg, Rayleigh P = {p:.3g}")
print("expected: no coupling, Rayleigh P >= 0.05 (paper P = 0.15)")
o2: RA-APs n 16985, vector length 0.379, angle 323 deg, Rayleigh P = 0 o4: RA-APs n 16985, vector length 0.375, angle 323 deg, Rayleigh P = 0 nosteady: RA-APs n 16967, vector length 0.379, angle 323 deg, Rayleigh P = 0 expected: no coupling, Rayleigh P >= 0.05 (paper P = 0.15)
Result: blocked (methods_underspecified). The mixture's lower-threshold component has the steeper mean slope (about 3.2 against 2.0 mV/ms), the opposite of the paper's RA-APs, so its classes are not the paper's and reading (a) cannot be run. The mixture is fitted to a seeded draw of 200,000 of the 291,968 APs, and its counts differ slightly between runs, so the numbers below are rounded; the exact ones are printed above. For the record, with these classes the 17,000 or so RA-APs are coupled too (323 degrees, length about 0.38, Rayleigh P printed as 0).
Up and down parts of the cycle (criterion of fig4-invivo-up-down-balance): (i) halves, up from 270 to 90 degrees through 0, down from 90 to 270; (ii) quarters centred on 0 (up, 315 to 45) and 180 degrees (down, 135 to 225). APs kept by the delta ratio, order 2.
K = PH[2][PH[2].ratio > 0.1]
for reading, up, down in (("(i) halves", lambda x: (x >= 270) | (x < 90), lambda x: (x >= 90) & (x < 270)),
("(ii) quarters", lambda x: (x >= 315) | (x < 45), lambda x: (x >= 135) & (x < 225))):
u, d = K[up(K.phase)], K[down(K.phase)]
ra_u, ais_u, ra_d, ais_d = int(u.ra.sum()), int((~u.ra).sum()), int(d.ra.sum()), int((~d.ra).sum())
s_u, s_d = ra_u / max(1, ra_u + ais_u), ra_d / max(1, ra_d + ais_d)
p = stats.fisher_exact([[ra_d, ais_d], [ra_u, ais_u]]).pvalue
print(f"{reading}: up AIS {ais_u}, RA {ra_u} (RA share {s_u:.3f}); down AIS {ais_d}, RA {ra_d} (RA share {s_d:.3f}); "
f"RA share higher in down: {s_d > s_u}; AIS outnumber RA in up: {ais_u > ra_u}; Fisher exact P = {p:.2g}")
(i) halves: up AIS 167487, RA 11861 (RA share 0.066); down AIS 57111, RA 5124 (RA share 0.082); RA share higher in down: True; AIS outnumber RA in up: True; Fisher exact P = 5.6e-41 (ii) quarters: up AIS 95848, RA 6577 (RA share 0.064); down AIS 19780, RA 1993 (RA share 0.092); RA share higher in down: True; AIS outnumber RA in up: True; Fisher exact P = 3.1e-44
Result: blocked (methods_underspecified). The mixture's lower-threshold component has the steeper mean slope (about 3.2 against 2.0 mV/ms), the opposite of the paper's RA-APs, so its classes are not the paper's and reading (a) cannot be run. The mixture is fitted to a seeded draw of 200,000 of the 291,968 APs, and its counts differ slightly between runs, so the numbers below are rounded; the exact ones are printed above. For the record, with these classes the RA-AP share is higher in the down half of the cycle (about 0.08 against 0.07, Fisher P below 1e-40) and AIS-APs outnumber RA-APs in the up half.
figs4i-ais-ra-frequency-correlation¶
Across in vivo cells, AIS-AP and RA-AP frequencies are weakly positively correlated (R = 0.29).
for label, d in (("all cells", Q), ("cells with RA-APs", Q[Q.n_ra > 0])):
r1, p1 = stats.pearsonr(d.f_ais, d.f_ra)
r2, p2 = stats.spearmanr(d.f_ais, d.f_ra)
print(f"{label} (n={len(d)}): Pearson R = {r1:.3f} (P = {p1:.2g}); Spearman R = {r2:.3f} (P = {p2:.2g})")
print("expected R = 0.29 (tolerance 0.029), P < 0.001")
all cells (n=259): Pearson R = 0.537 (P = 9.5e-21); Spearman R = 0.680 (P = 1.4e-36) cells with RA-APs (n=193): Pearson R = 0.510 (P = 3.6e-14); Spearman R = 0.612 (P = 3.2e-21) expected R = 0.29 (tolerance 0.029), P < 0.001
Result: blocked (methods_underspecified). The mixture's lower-threshold component has the steeper mean slope (about 3.2 against 2.0 mV/ms), the opposite of the paper's RA-APs, so its classes are not the paper's and reading (a) cannot be run. The mixture is fitted to a seeded draw of 200,000 of the 291,968 APs, and its counts differ slightly between runs, so the numbers below are rounded; the exact ones are printed above. For the record, with these classes the per-cell AIS-AP and RA-AP frequencies correlate with Pearson R of about 0.54 and Spearman R of about 0.68 over all 259 cells (P below 1e-19), about 0.51 and 0.61 over the cells with RA-APs.
figs5-not-genotype-or-anesthesia¶
RA-AP occurrence in vivo cannot be explained by mouse genotype or by anesthesia condition.
The genotype is in each file's subject/description; no field names the anesthesia condition
(data check). The genotype part is run as the criterion says: Mann-Whitney U tests between every
pair of genotypes, Bonferroni corrected, and a Kruskal-Wallis test.
G = Q.groupby("genotype")
print(G.agg(cells=("file", "size"), ra_freq_median=("f_ra", "median"), ais_freq_median=("f_ais", "median"),
with_ra=("n_ra", lambda x: float((x > 0).mean()))).round(4))
groups = {g: d.f_ra.to_numpy() for g, d in G if len(d) >= 2}
names = sorted(groups)
pairs = [(a, b) for i, a in enumerate(names) for b in names[i + 1:]]
for a, b in pairs:
p = stats.mannwhitneyu(groups[a], groups[b]).pvalue
print(f" {a} vs {b}: Mann-Whitney P = {p:.3g}, Bonferroni {min(1, p * len(pairs)):.3g}")
if len(groups) > 1:
print("Kruskal-Wallis across genotypes: P = %.3g" % stats.kruskal(*groups.values()).pvalue)
print(f"notebook time {(time.time() - T0) / 60:.1f} min, peak memory "
f"{resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1e6:.1f} GB")
cells ra_freq_median ais_freq_median with_ra genotype mouse 5 0.0142 0.2342 0.8000 mouse-GAD-GFP 79 0.0291 0.8455 0.7468 mouse-ai9 17 0.0060 0.0315 0.7647 mouse-black6 6 0.0079 0.7276 1.0000 mouse-vGATCreXai9 152 0.0073 0.3370 0.7303 mouse vs mouse-GAD-GFP: Mann-Whitney P = 0.529, Bonferroni 1 mouse vs mouse-ai9: Mann-Whitney P = 0.813, Bonferroni 1 mouse vs mouse-black6: Mann-Whitney P = 0.662, Bonferroni 1 mouse vs mouse-vGATCreXai9: Mann-Whitney P = 0.904, Bonferroni 1 mouse-GAD-GFP vs mouse-ai9: Mann-Whitney P = 0.266, Bonferroni 1 mouse-GAD-GFP vs mouse-black6: Mann-Whitney P = 0.273, Bonferroni 1 mouse-GAD-GFP vs mouse-vGATCreXai9: Mann-Whitney P = 0.0317, Bonferroni 0.317 mouse-ai9 vs mouse-black6: Mann-Whitney P = 1, Bonferroni 1 mouse-ai9 vs mouse-vGATCreXai9: Mann-Whitney P = 0.868, Bonferroni 1 mouse-black6 vs mouse-vGATCreXai9: Mann-Whitney P = 0.745, Bonferroni 1 Kruskal-Wallis across genotypes: P = 0.266 notebook time 42.0 min, peak memory 1.5 GB
Result: blocked (metadata_insufficient). No field of the in vivo files names the anesthesia condition (data check), so the condition part cannot be tested. The genotype is in subject/description (five values, including mouse and mouse-black6, which may be one strain). With the mixture classes, whose RA component has the steeper slope, RA-AP frequency does not differ by genotype (Kruskal-Wallis P near 0.27; smallest Bonferroni-corrected pairwise P near 0.3).
Summary¶
| Claim | Outcome |
|---|---|
| fig4b-invivo-ra-proportion | blocked, methods_underspecified |
| fig4i-invivo-frequencies | blocked, methods_underspecified |
| fig4g-invivo-ra-share | blocked, methods_underspecified |
| fig4f-invivo-pre-ap-fluctuation | blocked, methods_underspecified |
| fig4j-invivo-ais-phase-coupling | blocked, methods_underspecified |
| fig4j-invivo-ra-no-phase | blocked, methods_underspecified |
| fig4-invivo-up-down-balance | blocked, methods_underspecified |
| figs4i-ais-ra-frequency-correlation | blocked, methods_underspecified |
| figs5-not-genotype-or-anesthesia | blocked, metadata_insufficient |
How the analysis differs from the paper's. The dandiset has no AP labels. The one runnable reading of the claims file, a two-component mixture on threshold and pre-AP slope, gives a lower-threshold component with the steeper slope in these recordings, while the paper describes RA-APs as having the lower threshold and the lower slope. The claims are therefore blocked; the numbers under the mixture's classes are shown for each. The claims file's reading (b) does not ask for this check of the components; applied as written, it would give mixed outcomes (fig4-invivo-up-down-balance reproduced, fig4i and figs4i partially reproduced, as the verifier noted in round 2). The mixture is fitted to a seeded draw of 200,000 APs and its counts differ slightly between runs.
What was found about the dataset. The folder holds 259 files from 149 mice against the paper's 242
cells; 245 files have an LFP. In 135 of them every LFP series starts at the same time as a Vm series (median
fraction 1.000; in some files none does), and in 143 of the 167 files with at least 20 APs the
AP-triggered LFP average departs from its time-shifted value (|z| > 2, median z -10.4), which is
consistent with a shared clock. The
genotype is recorded in each file's subject description, the anesthesia condition nowhere. Some
files also hold camera images (Moovie).