OSCR

Distinctly structured social behavior across three rodent strains is associated with different neural activity patterns.

Code ↔ Paper

1 match between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 1 match
  1. [1] § STAR★Methods › Quantification and statistical analysis › Random forest classifier ↔ Feature_importances_mouse_rat.ipynb, lines 11–137 · score 0.58 · KNN, imputed, imputation, classification, scores, Shuffled

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: 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

  1. # %% [markdown]
  2. # ## Step 1: Import the data from one task and one stage at a time
  3. # %%
  4. import pandas as pd
  5. file_path = r"C:\Users\user\Desktop\rishika\Mice x Rats\cca pca\PCA mice x rats SP BL.xlsx"
  6. df_C57 = pd.read_excel(file_path, 'Sheet2')
  7. df_ICR = pd.read_excel(file_path, 'Sheet3')
  8. df_SD = pd.read_excel(file_path, 'Sheet4')
  9. # %% [markdown]
  10. # ## Step 2: Train the random forest classifier model; derive feature importances and acccuracy scores of models trained with true and shuffled labels
  11. # %%
  12. import numpy as np
  13. from sklearn.impute import KNNImputer
  14. from sklearn.ensemble import RandomForestClassifier
  15. from sklearn.model_selection import StratifiedKFold
  16. from sklearn.metrics import confusion_matrix, accuracy_score
  17. from sklearn.utils import shuffle
  18. features = df_C57.drop(columns=['Strains']).columns
  19. n_features = len(features)
  20. # ------------------
  21. # PARAMETERS
  22. # ------------------
  23. n_repeats = 100
  24. n_splits = 10
  25. # ------------------
  26. # STORING THE FEATURE IMPORTANCES
  27. # ------------------
  28. importances_true = np.zeros((n_repeats, n_splits, n_features))
  29. accs_true = np.zeros((n_repeats, n_splits))
  30. confusion_true = None
  31. importances_shuffle = np.zeros((n_repeats, n_splits, n_features))
  32. accs_shuffle = np.zeros((n_repeats, n_splits))
  33. confusion_shuffle = None
  34. # ------------------
  35. # DATA IMPUTATION USING A BUILT-IN KNN IMPUTER
  36. # ------------------
  37. def knn_impute_by_strain(df, random_state):
  38. feat_cols = df.drop(columns=['Strains']).columns
  39. df = shuffle(df, random_state=random_state).reset_index(drop=True)
  40. imputer = KNNImputer(n_neighbors=5)
  41. X_imp = imputer.fit_transform(df[feat_cols].values)
  42. out = pd.DataFrame(X_imp, columns=feat_cols)
  43. out['Strains'] = df['Strains'].values
  44. return out
  45. # ===========================================================
  46. # LOOP (true or shuffled labels)
  47. # ===========================================================
  48. for shuffle_flag in [False, True]:
  49. # pick storage
  50. importances = importances_shuffle if shuffle_flag else importances_true
  51. accs = accs_shuffle if shuffle_flag else accs_true
  52. conf_all = None
  53. for r in range(n_repeats):
  54. # ---- Impute each strain separately
  55. imp_C57 = knn_impute_by_strain(df_C57.copy(), random_state=r)
  56. imp_ICR = knn_impute_by_strain(df_ICR.copy(), random_state=r)
  57. imp_SD = knn_impute_by_strain(df_SD.copy(), random_state=r)
  58. df_imp = pd.concat([imp_C57, imp_ICR, imp_SD], axis=0).reset_index(drop=True)
  59. X = df_imp.drop(columns=['Strains']).values
  60. y = df_imp['Strains'].values
  61. if shuffle_flag:
  62. y = shuffle(y, random_state=r)
  63. skf = StratifiedKFold(n_splits=n_splits, shuffle=True, random_state=r)
  64. for f, (tr, te) in enumerate(skf.split(X, y)):
  65. Xtr, Xte = X[tr], X[te]
  66. ytr, yte = y[tr], y[te]
  67. clf = RandomForestClassifier(n_estimators=500, n_jobs=-1, random_state=f)
  68. clf.fit(Xtr, ytr)
  69. # Importance
  70. importances[r, f, :] = clf.feature_importances_
  71. # Accuracy
  72. preds = clf.predict(Xte)
  73. accs[r, f] = accuracy_score(yte, preds)
  74. # Confusion matrix
  75. cm = confusion_matrix(yte, preds, labels=np.unique(y))
  76. if conf_all is None:
  77. conf_all = cm.copy()
  78. else:
  79. conf_all += cm
  80. # store confusion
  81. if shuffle_flag:
  82. confusion_shuffle = conf_all
  83. else:
  84. confusion_true = conf_all
  85. # ==========================================
  86. # SUMMARY OUTPUTS
  87. # ==========================================
  88. # Mean importance
  89. df_true = pd.DataFrame({
  90. 'feature': features,
  91. 'mean_importance': importances_true.mean(axis=(0, 1)),
  92. 'std_importance': importances_true.std(axis=(0, 1))
  93. }).sort_values('mean_importance', ascending=False)
  94. df_shuffle = pd.DataFrame({
  95. 'feature': features,
  96. 'mean_importance': importances_shuffle.mean(axis=(0, 1)),
  97. 'std_importance': importances_shuffle.std(axis=(0, 1))
  98. }).sort_values('mean_importance', ascending=False)
  99. print("===== TRUE LABELS FEATURE IMPORTANCE RANKING =====")
  100. print(df_true.head(10))
  101. print("\n===== SHUFFLED LABELS FEATURE IMPORTANCE RANKING =====")
  102. print(df_shuffle.head(10))
  103. # Mean accuracies
  104. print("\nMean Accuracy (TRUE labels):", accs_true.mean())
  105. print("Mean Accuracy (SHUFFLED labels):", accs_shuffle.mean())
  106. # Confusion matrices
  107. print("\nConfusion Matrix (TRUE labels):\n", confusion_true)
  108. print("\nConfusion Matrix (SHUFFLED labels):\n", confusion_shuffle)
  109. # %% [markdown]
  110. # ## Step 3: Visualize the performance of classifiers
  111. # %%
  112. import matplotlib.pyplot as plt
  113. import seaborn as sns
  114. import numpy as np
  115. # Sort features by mean importance for plotting (optional)
  116. df_true_plot = df_true.sort_values("mean_importance", ascending=False)
  117. df_shuffle_plot = df_shuffle.sort_values("mean_importance", ascending=False)
  118. x = np.arange(len(features))
  119. labels = df_true_plot["feature"].values
  120. # ----- FIGURE -----
  121. plt.figure(figsize=(16, 10))
  122. # --- True Labels Feature Importance ---
  123. plt.subplot(2, 1, 1)
  124. plt.bar(x, df_true_plot["mean_importance"], yerr=df_true_plot["std_importance"], capsize=3)
  125. plt.xticks(x, labels, rotation=90)
  126. plt.ylabel("Feature importance")
  127. plt.title("Random Forest Feature Importance (TRUE labels)")
  128. # --- Shuffled Labels Feature Importance ---
  129. plt.subplot(2, 1, 2)
  130. plt.bar(x, df_shuffle_plot["mean_importance"], yerr=df_shuffle_plot["std_importance"], color='orange', capsize=3)
  131. plt.xticks(x, labels, rotation=90)
  132. plt.ylabel("Feature importance")
  133. plt.title("Random Forest Feature Importance (SHUFFLED labels)")
  134. plt.tight_layout()
  135. plt.show()
  136. # ----- CONFUSION MATRICES HEATMAPS -----
  137. strain_order = ['C57', 'ICR', 'SD']
  138. def plot_cm_heatmap(cm, title):
  139. cm_percent = cm / cm.sum(axis=1, keepdims=True) * 100 # convert to percentage
  140. plt.figure(figsize=(6,5))
  141. sns.heatmap(cm_percent, annot=True, fmt=".1f", cmap="Blues", xticklabels=strain_order, yticklabels=strain_order)
  142. plt.ylabel("True label")
  143. plt.xlabel("Predicted label")
  144. plt.title(title)
  145. plt.show()
  146. # True labels
  147. plot_cm_heatmap(confusion_true, "Confusion Matrix (TRUE labels)")
  148. # Shuffled labels
  149. plot_cm_heatmap(confusion_shuffle, "Confusion Matrix (SHUFFLED labels)")
  150. # %% [markdown]
  151. # ## Step 4: Export the accuracy scores of classifiers as csv files for comparison
  152. # %%
  153. import numpy as np
  154. # Flatten
  155. acc_true_flat = accs_true.flatten() # length = 1000
  156. acc_shuffle_flat = accs_shuffle.flatten() # length = 1000
  157. n_repeats, n_splits = accs_true.shape # should be (100,10)
  158. # base indexes for true
  159. repeat_idx_base = np.repeat(np.arange(1, n_repeats+1), n_splits)
  160. fold_idx_base = np.tile(np.arange(1, n_splits+1), n_repeats)
  161. # Duplicate them for shuffled
  162. repeat_idx = np.concatenate([repeat_idx_base, repeat_idx_base])
  163. fold_idx = np.concatenate([fold_idx_base, fold_idx_base])
  164. # Final dataframe
  165. df_acc = pd.DataFrame({
  166. 'Imputation': repeat_idx,
  167. 'Fold': fold_idx,
  168. 'Accuracy': np.concatenate([acc_true_flat, acc_shuffle_flat]),
  169. 'Label_type': ['True']*len(acc_true_flat) + ['Shuffled']*len(acc_shuffle_flat)
  170. })
  171. print(df_acc.head())
  172. print(df_acc.tail())
  173. # Save if you want
  174. df_acc.to_csv("accuracy_per_fold_imputation_sp_bl.csv", index=False)
  175. # %% [markdown]
  176. # ## Step 5: Export the sorted feature importance values for comparisons and plotting
  177. # %%
  178. # Sort df_true descending
  179. df_true_sorted = df_true.sort_values('mean_importance', ascending=False)
  180. # Reindex df_shuffle so it follows the same feature order as df_true_sorted
  181. df_shuffle_sorted = df_shuffle.set_index('feature').loc[df_true_sorted['feature']].reset_index()
  182. df_true_sorted.to_csv('feature_importance_true_SP_BL.csv', index=False)
  183. df_shuffle_sorted.to_csv('feature_importance_shuffled_SP_BL.csv', index=False)
  184. # %%

Feature_importances_mouse_rat.ipynb at commit c3d46d7, no license · at the source

Overview

Authors: Rishika Tiwari1, Alok Nath Mohapatra2,3,4, Claudio J. Mendes Jr.1, Renad Jabarin1, Shai Netser1, Shlomo Wagner1
ORCID iDs: Shlomo Wagner
  1. Sagol Department of Neurobiology, Faculty of Natural Sciences, University of Haifa, Haifa, Israel
  2. Department of Psychiatry, Massachusetts General Hospital, Harvard Medical School, Boston, MA, USA
  3. Harvard Stem Cell Institute, Cambridge, MA, USA
  4. BROAD Institute of MIT and Harvard, Cambridge, MA, USA
Institutions: University of Haifa (Israel); Broad Institute (United States); Harvard University (United States); Massachusetts General Hospital (United States); Harvard Stem Cell Institute (United States)
Journal: iScience, volume 29, issue 8, article 116119
Dates: received 20 November 2025; accepted 11 May 2026; published online 20 July 2026
Type: Research article · Language: English
License: CC BY-NC
Identifiers: DOI 10.1016/j.isci.2026.116119 · PMID 42495538 · PMCID PMC13393703 · OpenAlex W7169767208
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: mouse (organism), rat (organism)
Methods: Spectral & time-frequency, Statistics, Smoothing, state filtering, decompositions, Machine learning, Connectivity, Preprocessing
Topic: Neuroendocrine regulation and behavior (Social Psychology, Psychology), according to OpenAlex
Citations: not cited yet (Europe PMC); 48 references in the paper

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/6J and CD1 mice and SD rats) in social preference and free interaction tasks. Animals carried chronically implanted electrodes in brain regions associated with social motivation. The three strains exhibited distinctly structured social behavior: SD rats showed the strongest social motivation, CD1 mice were most active, and C57BL/6J mice displayed the most restrained behavior. Electrophysiology revealed strain- and task-specific theta and gamma power and coherence. Strikingly, SD rats displayed low baseline coherence followed by robust induction during interactions, while C57BL/6J mice exhibited opposite tendencies. Machine learning models allowed accurate strain separation based solely on brain electrophysiology, with theta and gamma coherence between the prelimbic cortex and nucleus accumbens shell playing a key role in defining distinct neuronal signatures of strain-specific social strategies.

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

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: c3d46d7a80419b4b3d44828deb53c639b982ed88, 12 October 2025
Languages: Jupyter (3), Python (3)
Size: 6 files, 6 scripts
Software Heritage: not archived
Found in: the text, “Random forest classifier”
Holds: 3 notebooks
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: NumPy (6 files), pandas (6 files), SciPy (4 files), Matplotlib (3 files), scikit-learn (2 files), seaborn (2 files)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
6 files

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

Data and code availability

• All data and codes are available at Mendeley data: https://doi.org/10.17632/zpb4vhkyvg.1. • Any additional information required to reanalyze the data reported in this manuscript will be available from the lead contact upon request.

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://doi.org/10.1016/j.isci.2026.116119

BibTeX

@article{tiwari2026distinctly,
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/j.isci.2026.116119},
url = {https://doi.org/10.1016/j.isci.2026.116119},
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/07/20
VL - 29
IS - 8
SP - 116119
SN - 2589-0042
PB - Elsevier
DO - 10.1016/j.isci.2026.116119
UR - https://doi.org/10.1016/j.isci.2026.116119
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.isci.2026.116119",
"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": "iScience",
"volume": "29",
"issue": "8",
"page": "116119",
"DOI": "10.1016/j.isci.2026.116119",
"PMID": "42495538",
"PMCID": "PMC13393703",
"ISSN": "2589-0042",
"publisher": "Elsevier",
"URL": "https://doi.org/10.1016/j.isci.2026.116119",
"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-026-10089-z [code]
Medial prefrontal cortex neurons integrate amygdala and hypothalamic oxytocin signals to mediate stress-induced social alterations.
Journal: Communications biology
In common: seaborn, scikit-learn, pandas, 3 other tools, mouse, 2 references
[2] 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 Neuropsychopharmacology
In common: seaborn, scikit-learn, pandas, 3 other tools, mouse, 2 references
[3] doi:10.1162/imag.a.1229 [code]
40 Hz audiovisual stimulation improves sustained attention and related brain oscillations.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: seaborn, pandas, SciPy, 2 other tools, 3 references
[4] doi:10.1016/j.isci.2026.116825 [code]
Social hierarchy shapes behavioral and transcriptional responses to chronic stress and ketamine in male mice.
Journal: iScience
In common: seaborn, scikit-learn, pandas, 3 other tools, mouse, 2 references
[5] doi:10.1371/journal.pcbi.1013488 [code]
Evaluating place cell detection methods in Rats and Humans: Implications for cross-species spatial coding.
Journal: PLoS computational biology
In common: seaborn, scikit-learn, pandas, 3 other tools, rat, 1 reference
[6] doi:10.1016/j.neuron.2026.05.004 [code]
A learning-evoked slow-oscillatory architecture paces population activity for offline reactivation across the human medial temporal lobe.
Journal: Neuron
In common: seaborn, SciPy, Matplotlib, 1 other tool, 3 references
[7] doi:10.1038/s41467-026-70287-5 [code]
Cortical-limbic circuit dynamics of approach-avoidance conflict in humans.
Journal: Nature communications
In common: seaborn, pandas, SciPy, 2 other tools, 2 references
[8] doi:10.1002/advs.202518450 [code]
A Brain-Wide Atlas of Astrocytic Oxytocin Receptors Reveals a Glial Basis for Nucleus Accumbens Modulation of Affiliative Behavior.
Journal: Advanced science (Weinheim, Baden-Wurttemberg, Germany)
In common: seaborn, pandas, SciPy, 2 other tools, rat, mouse, 1 reference
[9] doi:10.1038/s41586-026-10331-y [code]
Active dissociation of intracortical spiking and high gamma activity.
Journal: Nature
In common: scikit-learn, pandas, SciPy, 2 other tools, 2 references
[10] doi:10.1162/imag.a.1348 [code]
The role of high-amplitude bursts of high-gamma activity in naturalistic speech and music listening.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: seaborn, pandas, SciPy, 2 other tools, 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.

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: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.