Distinctly structured social behavior across three rodent strains is associated with different neural activity patterns.
The 1 match
- [1] § STAR★Methods › Quantification and statistical analysis › Random forest classifier ↔ Feature_importances_mouse_rat.ipynb, lines 11 to 137 · score 0.58 · KNN, imputed, imputation, classification, scores, Shuffled · Report a mismatch
Paper
Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
Jupyter notebook · 239 lines · 7.7 KB · no license · 1 match
- # %% [markdown]
- # ## Step 1: Import the data from one task and one stage at a time
- # %%
- import pandas as pd
- file_path = r"C:\Users\user\Desktop\rishika\Mice x Rats\cca pca\PCA mice x rats SP BL.xlsx"
- df_C57 = pd.read_excel(file_path, 'Sheet2')
- df_ICR = pd.read_excel(file_path, 'Sheet3')
- df_SD = pd.read_excel(file_path, 'Sheet4')
- # %% [markdown]
- # ## Step 2: Train the random forest classifier model; derive feature importances and acccuracy scores of models trained with true and shuffled labels
- # %%
- import numpy as np
- from sklearn.impute import KNNImputer
- from sklearn.ensemble import RandomForestClassifier
- from sklearn.model_selection import StratifiedKFold
- from sklearn.metrics import confusion_matrix, accuracy_score
- from sklearn.utils import shuffle
- features = df_C57.drop(columns=['Strains']).columns
- n_features = len(features)
- # ------------------
- # PARAMETERS
- # ------------------
- n_repeats = 100
- n_splits = 10
- # ------------------
- # STORING THE FEATURE IMPORTANCES
- # ------------------
- importances_true = np.zeros((n_repeats, n_splits, n_features))
- accs_true = np.zeros((n_repeats, n_splits))
- confusion_true = None
- importances_shuffle = np.zeros((n_repeats, n_splits, n_features))
- accs_shuffle = np.zeros((n_repeats, n_splits))
- confusion_shuffle = None
- # ------------------
- # DATA IMPUTATION USING A BUILT-IN KNN IMPUTER
- # ------------------
- def knn_impute_by_strain(df, random_state):
- feat_cols = df.drop(columns=['Strains']).columns
- df = shuffle(df, random_state=random_state).reset_index(drop=True)
- imputer = KNNImputer(n_neighbors=5)
- X_imp = imputer.fit_transform(df[feat_cols].values)
- out = pd.DataFrame(X_imp, columns=feat_cols)
- out['Strains'] = df['Strains'].values
- return out
- # ===========================================================
- # LOOP (true or shuffled labels)
- # ===========================================================
- for shuffle_flag in [False, True]:
- # pick storage
- importances = importances_shuffle if shuffle_flag else importances_true
- accs = accs_shuffle if shuffle_flag else accs_true
- conf_all = None
- for r in range(n_repeats):
- # ---- Impute each strain separately
- imp_C57 = knn_impute_by_strain(df_C57.copy(), random_state=r)
- imp_ICR = knn_impute_by_strain(df_ICR.copy(), random_state=r)
- imp_SD = knn_impute_by_strain(df_SD.copy(), random_state=r)
- df_imp = pd.concat([imp_C57, imp_ICR, imp_SD], axis=0).reset_index(drop=True)
- X = df_imp.drop(columns=['Strains']).values
- y = df_imp['Strains'].values
- if shuffle_flag:
- y = shuffle(y, random_state=r)
- skf = StratifiedKFold(n_splits=n_splits, shuffle=True, random_state=r)
- for f, (tr, te) in enumerate(skf.split(X, y)):
- Xtr, Xte = X[tr], X[te]
- ytr, yte = y[tr], y[te]
- clf = RandomForestClassifier(n_estimators=500, n_jobs=-1, random_state=f)
- clf.fit(Xtr, ytr)
- # Importance
- importances[r, f, :] = clf.feature_importances_
- # Accuracy
- preds = clf.predict(Xte)
- accs[r, f] = accuracy_score(yte, preds)
- # Confusion matrix
- cm = confusion_matrix(yte, preds, labels=np.unique(y))
- if conf_all is None:
- conf_all = cm.copy()
- else:
- conf_all += cm
- # store confusion
- if shuffle_flag:
- confusion_shuffle = conf_all
- else:
- confusion_true = conf_all
- # ==========================================
- # SUMMARY OUTPUTS
- # ==========================================
- # Mean importance
- df_true = pd.DataFrame({
- 'feature': features,
- 'mean_importance': importances_true.mean(axis=(0, 1)),
- 'std_importance': importances_true.std(axis=(0, 1))
- }).sort_values('mean_importance', ascending=False)
- df_shuffle = pd.DataFrame({
- 'feature': features,
- 'mean_importance': importances_shuffle.mean(axis=(0, 1)),
- 'std_importance': importances_shuffle.std(axis=(0, 1))
- }).sort_values('mean_importance', ascending=False)
- print("===== TRUE LABELS FEATURE IMPORTANCE RANKING =====")
- print(df_true.head(10))
- print("\n===== SHUFFLED LABELS FEATURE IMPORTANCE RANKING =====")
- print(df_shuffle.head(10))
- # Mean accuracies
- print("\nMean Accuracy (TRUE labels):", accs_true.mean())
- print("Mean Accuracy (SHUFFLED labels):", accs_shuffle.mean())
- # Confusion matrices
- print("\nConfusion Matrix (TRUE labels):\n", confusion_true)
- print("\nConfusion Matrix (SHUFFLED labels):\n", confusion_shuffle)
- # %% [markdown]
- # ## Step 3: Visualize the performance of classifiers
- # %%
- import matplotlib.pyplot as plt
- import seaborn as sns
- import numpy as np
- # Sort features by mean importance for plotting (optional)
- df_true_plot = df_true.sort_values("mean_importance", ascending=False)
- df_shuffle_plot = df_shuffle.sort_values("mean_importance", ascending=False)
- x = np.arange(len(features))
- labels = df_true_plot["feature"].values
- # ----- FIGURE -----
- plt.figure(figsize=(16, 10))
- # --- True Labels Feature Importance ---
- plt.subplot(2, 1, 1)
- plt.bar(x, df_true_plot["mean_importance"], yerr=df_true_plot["std_importance"], capsize=3)
- plt.xticks(x, labels, rotation=90)
- plt.ylabel("Feature importance")
- plt.title("Random Forest Feature Importance (TRUE labels)")
- # --- Shuffled Labels Feature Importance ---
- plt.subplot(2, 1, 2)
- plt.bar(x, df_shuffle_plot["mean_importance"], yerr=df_shuffle_plot["std_importance"], color='orange', capsize=3)
- plt.xticks(x, labels, rotation=90)
- plt.ylabel("Feature importance")
- plt.title("Random Forest Feature Importance (SHUFFLED labels)")
- plt.tight_layout()
- plt.show()
- # ----- CONFUSION MATRICES HEATMAPS -----
- strain_order = ['C57', 'ICR', 'SD']
- def plot_cm_heatmap(cm, title):
- cm_percent = cm / cm.sum(axis=1, keepdims=True) * 100 # convert to percentage
- plt.figure(figsize=(6,5))
- sns.heatmap(cm_percent, annot=True, fmt=".1f", cmap="Blues", xticklabels=strain_order, yticklabels=strain_order)
- plt.ylabel("True label")
- plt.xlabel("Predicted label")
- plt.title(title)
- plt.show()
- # True labels
- plot_cm_heatmap(confusion_true, "Confusion Matrix (TRUE labels)")
- # Shuffled labels
- plot_cm_heatmap(confusion_shuffle, "Confusion Matrix (SHUFFLED labels)")
- # %% [markdown]
- # ## Step 4: Export the accuracy scores of classifiers as csv files for comparison
- # %%
- import numpy as np
- # Flatten
- acc_true_flat = accs_true.flatten() # length = 1000
- acc_shuffle_flat = accs_shuffle.flatten() # length = 1000
- n_repeats, n_splits = accs_true.shape # should be (100,10)
- # base indexes for true
- repeat_idx_base = np.repeat(np.arange(1, n_repeats+1), n_splits)
- fold_idx_base = np.tile(np.arange(1, n_splits+1), n_repeats)
- # Duplicate them for shuffled
- repeat_idx = np.concatenate([repeat_idx_base, repeat_idx_base])
- fold_idx = np.concatenate([fold_idx_base, fold_idx_base])
- # Final dataframe
- df_acc = pd.DataFrame({
- 'Imputation': repeat_idx,
- 'Fold': fold_idx,
- 'Accuracy': np.concatenate([acc_true_flat, acc_shuffle_flat]),
- 'Label_type': ['True']*len(acc_true_flat) + ['Shuffled']*len(acc_shuffle_flat)
- })
- print(df_acc.head())
- print(df_acc.tail())
- # Save if you want
- df_acc.to_csv("accuracy_per_fold_imputation_sp_bl.csv", index=False)
- # %% [markdown]
- # ## Step 5: Export the sorted feature importance values for comparisons and plotting
- # %%
- # Sort df_true descending
- df_true_sorted = df_true.sort_values('mean_importance', ascending=False)
- # Reindex df_shuffle so it follows the same feature order as df_true_sorted
- df_shuffle_sorted = df_shuffle.set_index('feature').loc[df_true_sorted['feature']].reset_index()
- df_true_sorted.to_csv('feature_importance_true_SP_BL.csv', index=False)
- df_shuffle_sorted.to_csv('feature_importance_shuffled_SP_BL.csv', index=False)
- # %%
Feature_importances_mouse_rat.ipynb at commit c3d46d7, no license · at the source
Overview
- Sagol Department of Neurobiology, Faculty of Natural Sciences, University of Haifa, Haifa, Israel
- Department of Psychiatry, Massachusetts General Hospital, Harvard Medical School, Boston, MA, USA
- Harvard Stem Cell Institute, Cambridge, MA, USA
- BROAD Institute of MIT and Harvard, Cambridge, MA, USA
Abstract
Social behavior varies considerably across mammalian species, yet the neural basis for these variations remains unclear. We compared the behavior of three commonly used laboratory rodent strains (C57BL/
Reproduced under the paper's license (CC BY-NC), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.
98rishika/Mouse-rat_analysis
c3d46d7a80419b4b3d44828deb53c639b982ed88, 12 October 2025Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
6 files
- Feature_importances_mous
e_rat.ipynb , Jupyter, 239 lines, 1 match - PCA_mouse_rat.ipynb, Jupyter, 380 lines
- cohen d.ipynb, Jupyter, 69 lines
- feature_extract_custom_C
D1.py , Python, 799 lines - feature_extract_custom_S
D.py , Python, 775 lines - feature_extract_custom_c
57.py , Python, 775 lines
The paper's code and data availability statement is in the Data section.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 6 scripts, each with its path and the digest of its content;
- 1 match between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
Datasets cited
- doi:10.17632/
zpb4vhkyvg.1 , at the source; found in “Data and code availability”
Data and code availability
• All data and codes are available at Mendeley data: https://
Reproduced under the paper's license (CC BY-NC), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 7 funders, 48 references.
Cite
This paper
Tiwari, R., Mohapatra, A. N., Mendes, C. J., Jabarin, R., Netser, S., & Wagner, S. (2026). Distinctly structured social behavior across three rodent strains is associated with different neural activity patterns. iScience, 29(8), 116119. https://
BibTeX
@article{tiwari2026disti
author = {Tiwari, Rishika and Mohapatra, Alok Nath and Mendes, Claudio J. and Jabarin, Renad and Netser, Shai and Wagner, Shlomo},
title = {{Distinctly structured social behavior across three rodent strains is associated with different neural activity patterns}},
journal = {iScience},
year = {2026},
month = jul,
volume = {29},
number = {8},
pages = {116119},
publisher = {Elsevier},
issn = {2589-0042},
doi = {10.1016/
url = {https://
pmid = {42495538},
pmcid = {PMC13393703}
}
RIS
TY - JOUR
AU - Tiwari, Rishika
AU - Mohapatra, Alok Nath
AU - Mendes, Claudio J.
AU - Jabarin, Renad
AU - Netser, Shai
AU - Wagner, Shlomo
TI - Distinctly structured social behavior across three rodent strains is associated with different neural activity patterns
T2 - iScience
J2 - iScience
PY - 2026
DA - 2026/
VL - 29
IS - 8
SP - 116119
SN - 2589-0042
PB - Elsevier
DO - 10.1016/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1016/
"type": "article-journal",
"title": "Distinctly structured social behavior across three rodent strains is associated with different neural activity patterns",
"container-title": "iScience",
"author": [
{
"family": "Tiwari",
"given": "Rishika"
},
{
"family": "Mohapatra",
"given": "Alok Nath"
},
{
"family": "Mendes",
"given": "Claudio J."
},
{
"family": "Jabarin",
"given": "Renad"
},
{
"family": "Netser",
"given": "Shai"
},
{
"family": "Wagner",
"given": "Shlomo"
}
],
"container-title-short":
"volume": "29",
"issue": "8",
"page": "116119",
"DOI": "10.1016/
"PMID": "42495538",
"PMCID": "PMC13393703",
"ISSN": "2589-0042",
"publisher": "Elsevier",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
20
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1038/s42003-023-05728-8 [code]
- Synchronized LFP rhythmicity in the social brain reflects the context of social encounters.Journal: Communications biologyIn common: mouse, 12 references, author Shlomo Wagner
- [2] doi:10.1038/s41380-024-02754-8 [code]
- Impaired emotion recognition in Cntnap2-deficient mice is associated with hyper-synchronous prefrontal cortex neuronal activity.Journal: Molecular psychiatryIn common: mouse, 7 references, author Shlomo Wagner
- [3] doi:10.1038/s41467-026-68347-x [code]
- Oxytocin facilitates social behavior of female rats via selective modulation of interneurons in the medial prefrontal cortex.Journal: Nature communicationsIn common: pandas, SciPy, Matplotlib, 1 other tool, rat, 1 reference, author Shlomo Wagner
- [4] doi:10.1016/j.isci.2022.105921
- Modulation of social investigation by anterior hypothalamic nucleus rhythmic neural activity.Journal: iScienceIn common: 3 references, author Shlomo Wagner
- [5] doi:10.1007/s43440-024-00679-1 [code]
- Assessing the effects of 5-HT<sub>2A</
sub> and 5-HT<sub>5A</ sub> receptor antagonists on DOI-induced head-twitch response in male rats using marker-less deep learning algorithms. Journal: Pharmacological reports : PRIn common: seaborn, scikit-learn, pandas, 3 other tools, rat, 3 references - [6] doi:10.1016/j.cell.2023.08.010 [code]
- Corticotropin-releasing hormone signaling from prefrontal cortex to lateral septum suppresses interaction with familiar mice.Journal: CellIn common: scikit-learn, pandas, SciPy, 2 other tools, mouse, 3 references
- [7] doi:10.7554/elife.79545 [code]
- Rhythmic coordination and ensemble dynamics in the hippocampal-prefrontal network during odor-place associative memory and decision making.Journal: eLifeIn common: seaborn, scikit-learn, pandas, 3 other tools, rat, 2 references
- [8] doi:10.1016/j.isci.2026.114694 [code]
- Dissociating neural circuits of social and prosocial reward in rat helping behavior.Journal: iScienceIn common: seaborn, scikit-learn, pandas, 3 other tools, rat, 2 references
- [9] doi:10.7554/elife.91765 [code]
- Post-ejaculatory inhibition of female sexual drive via heterogeneous neuronal ensembles in the medial preoptic area.Journal: eLifeIn common: seaborn, scikit-learn, pandas, 3 other tools, mouse, 2 references
- [10] doi:10.1038/s41386-026-02492-1 [code]
- Proximity in mice induced by an auditory-conditioned stimulus.Journal: Neuropsychopharmacology : official publication of the American College of NeuropsychopharmacologyIn common: seaborn, scikit-learn, pandas, 3 other tools, mouse, 2 references
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 6 scripts, and 1 match between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:83d4167262a085cd…
Add the badge to the code's README
If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.
Markdown
<!-- oscr-badge:start -->
[](https://openscicode.org/badge/doi/10.1016/j.isci.2026.116119)
<!-- oscr-badge:end -->reStructuredText
.. oscr-badge:start
.. image:: https://openscicode.org/badge/doi/10.1016/j.isci.2026.116119.svg
:target: https://openscicode.org/badge/doi/10.1016/j.isci.2026.116119
:alt: OSCR
.. oscr-badge:endHTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1016/j.isci.2026.116119"><img src="https://openscicode.org/badge/doi/10.1016/j.isci.2026.116119.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".
If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.
Report a mismatch between the code and the paper · Report a code error (signed in)
Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.
Report a reproduction failure (signed in)
Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
