OSCR

HarveST uses a heterogeneous graph learning framework to reveal spatial transcriptomics patterns.

Code ↔ Paper

4 matches 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 4 matches
  1. [1] § Methods › Random walk with restart for spatially specific gene detection ↔ harvest/spatial_gene_discovery.py, lines 346 to 386 · score 0.73 · initial probability vector, restart probability, RWR converges, iteratively, walk, seed · Report a mismatch
  2. [2] § Methods › Heterogeneous graph construction › Gene-gene subgraph ↔ harvest/model/graph_nn.py, lines 11 to 81 · score 0.63 · MI scores, adjacency matrix, Mutual Information, dimensional, weighted, network · Report a mismatch
  3. [3] § Methods › Heterogeneous graph construction › Joint analysis ↔ harvest/model/graph_nn.py, lines 11 to 81 · score 0.57 · graph neural network, mutual information matrix, dimensional, adjacency · Report a mismatch
  4. [4] § Methods › Heterogeneous graph construction › Gene-gene subgraph ↔ harvest/preprocessing/mutual_information.py, lines 11 to 78 · score 0.51 · gene pairs, Mutual Information, computationally, MI, matrix · 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

Python · 172 lines · 6.9 KB · MIT · 2 matches

  1. import torch
  2. import torch.nn as nn
  3. import torch.nn.functional as F
  4. from torch.nn.parameter import Parameter
  5. from .attention import AttentionLayers
  6. class GraphNeuralNetwork(nn.Module):
  7. """Graph Neural Network with attention mechanisms for spatial transcriptomics."""
  8. def __init__(self, hidden_dims_c: list, hidden_dims_g: list,
  9. adjacency_matrix: torch.Tensor, mi_score: torch.Tensor,
  10. cg_expr: torch.Tensor, coor_ratio: float = 1.0):
  11. """
  12. Initialize the Graph Neural Network.
  13. Parameters:
  14. -----------
  15. hidden_dims_c : list
  16. Dimensions of cell representation layers
  17. hidden_dims_g : list
  18. Dimensions of gene representation layers
  19. adjacency_matrix : torch.Tensor
  20. Cell-to-cell adjacency matrix
  21. mi_score : torch.Tensor
  22. Gene-to-gene mutual information matrix
  23. cg_expr : torch.Tensor
  24. Cell-to-gene expression matrix
  25. coor_ratio : float
  26. Coordination ratio parameter
  27. """
  28. super(GraphNeuralNetwork, self).__init__()
  29. self.n_layers = len(hidden_dims_c) - 1
  30. self.adj = adjacency_matrix
  31. self.mi = mi_score
  32. self.expr = cg_expr
  33. self.coor_ratio = coor_ratio
  34. # Attention dictionaries
  35. self.atten = {}
  36. self.atten_g = {}
  37. self.atten_gg = {}
  38. # Weight matrices
  39. self.W_c = nn.ParameterList([
  40. Parameter(torch.FloatTensor(hidden_dims_c[i], hidden_dims_c[i+1]))
  41. for i in range(self.n_layers)
  42. ])
  43. self.W_g = nn.ParameterList([
  44. Parameter(torch.FloatTensor(hidden_dims_g[i], hidden_dims_g[i+1]))
  45. for i in range(self.n_layers)
  46. ])
  47. self.W_gc = nn.ParameterList([
  48. Parameter(torch.FloatTensor(hidden_dims_g[1], hidden_dims_g[2]))
  49. ])
  50. # Attention parameters
  51. self.Ws_att = nn.ParameterList([])
  52. self.Ws_att_g = nn.ParameterList([])
  53. self.Ws_att_gg = nn.ParameterList([])
  54. for i in range(self.n_layers-1):
  55. v = nn.ParameterList([])
  56. v.append(Parameter(torch.FloatTensor(hidden_dims_c[i+1], 1)))
  57. v.append(Parameter(torch.FloatTensor(hidden_dims_c[i+1], 1)))
  58. self.Ws_att.append(v)
  59. for i in range(self.n_layers-1):
  60. v = nn.ParameterList([])
  61. v.append(Parameter(torch.FloatTensor(hidden_dims_g[i+1], 1)))
  62. v.append(Parameter(torch.FloatTensor(hidden_dims_g[i+1], 1)))
  63. self.Ws_att_g.append(v)
  64. for i in range(self.n_layers-1):
  65. v = nn.ParameterList([])
  66. v.append(Parameter(torch.FloatTensor(hidden_dims_c[i+1], 1)))
  67. v.append(Parameter(torch.FloatTensor(hidden_dims_c[i+1], 1)))
  68. self.Ws_att_gg.append(v)
  69. # Initialize parameters
  70. self._initialize_parameters()
  71. def _initialize_parameters(self):
  72. """Initialize network parameters with Xavier initialization."""
  73. torch.nn.init.xavier_uniform_(self.Ws_att[0][0])
  74. torch.nn.init.xavier_uniform_(self.Ws_att[0][1])
  75. torch.nn.init.xavier_uniform_(self.Ws_att_g[0][0])
  76. torch.nn.init.xavier_uniform_(self.Ws_att_g[0][1])
  77. torch.nn.init.xavier_uniform_(self.Ws_att_gg[0][0])
  78. torch.nn.init.xavier_uniform_(self.Ws_att_gg[0][1])
  79. torch.nn.init.xavier_uniform_(self.W_c[0])
  80. torch.nn.init.xavier_uniform_(self.W_c[1])
  81. torch.nn.init.xavier_uniform_(self.W_gc[0])
  82. torch.nn.init.xavier_uniform_(self.W_g[0])
  83. torch.nn.init.xavier_uniform_(self.W_g[1])
  84. def forward(self, X_c: torch.Tensor, X_g: torch.Tensor):
  85. """
  86. Forward pass through the network.
  87. Parameters:
  88. -----------
  89. X_c : torch.Tensor
  90. Cell features
  91. X_g : torch.Tensor
  92. Gene features
  93. Returns:
  94. --------
  95. tuple : (hidden, hidden_coor, reX_c, reX_g)
  96. Final embeddings and reconstructed features
  97. """
  98. H_g = X_g
  99. H_c = X_c
  100. for layer in range(self.n_layers):
  101. H_c, H_g, H_c_coor, H_c_expr = self.encoder(H_c, H_g, self.mi, self.adj, self.expr, layer)
  102. if layer != self.n_layers-1:
  103. H_c = F.elu(H_c)
  104. H_g = F.elu(H_g)
  105. H_c_coor = F.elu(H_c_coor)
  106. H_c_expr = F.elu(H_c_expr)
  107. hidden = H_c
  108. hidden_coor = H_c_coor
  109. for layer in range(self.n_layers-1, -1, -1):
  110. H_c_coor, H_c_expr = self.decoder(H_c_coor, H_c_expr, self.adj, self.expr, self.mi, layer)
  111. if layer != 0:
  112. H_c_coor = F.elu(H_c_coor)
  113. H_c_expr = F.elu(H_c_expr)
  114. reX_c = H_c_coor
  115. reX_g = H_c_expr
  116. return hidden, hidden_coor, reX_c, reX_g
  117. def encoder(self, X_c: torch.Tensor, X_g: torch.Tensor, mi: torch.Tensor,
  118. adj: torch.Tensor, expr: torch.Tensor, layer: int):
  119. """Encoder part of the network."""
  120. if layer != self.n_layers-1:
  121. z_g = torch.mm(X_g, self.W_g[layer])
  122. self.atten_gg[layer] = AttentionLayers.graph_attention_layer_gg(mi, z_g, self.Ws_att_gg[0])
  123. z_g = torch.mm(self.atten_gg[layer], z_g)
  124. z_c = torch.mm(X_c, self.W_c[layer])
  125. z_c_coor = torch.tensor(0, dtype=torch.float)
  126. z_c_expr = torch.tensor(0, dtype=torch.float)
  127. return z_c, z_g, z_c_coor, z_c_expr
  128. elif layer == self.n_layers-1:
  129. self.atten[layer] = AttentionLayers.graph_attention_layer(adj, X_c, self.Ws_att[0])
  130. z_c_coor = torch.mm(self.atten[layer], X_c)
  131. z_c_coor = torch.mm(z_c_coor, self.W_c[layer])
  132. self.atten_g[layer] = AttentionLayers.graph_attention_layer_g(expr, X_g, self.Ws_att_g[0])
  133. z_c_expr = torch.mm(self.atten_g[layer], X_g)
  134. z_c_expr = torch.mm(z_c_expr, self.W_gc[0])
  135. z_c = self.coor_ratio * z_c_coor + (1 - self.coor_ratio) * z_c_expr
  136. return z_c, X_g, z_c_coor, z_c_expr
  137. def decoder(self, z_c_coor: torch.Tensor, z_c_expr: torch.Tensor,
  138. adj: torch.Tensor, expr: torch.Tensor, mi: torch.Tensor, layer: int):
  139. """Decoder part of the network."""
  140. if layer == 0:
  141. D_c_coor = torch.mm(z_c_coor, torch.transpose(self.W_c[layer], 1, 0))
  142. D_expr = torch.mm(self.atten_gg[layer], z_c_expr)
  143. D_expr = torch.mm(D_expr, torch.transpose(self.W_g[0], 1, 0))
  144. return D_c_coor, D_expr
  145. else:
  146. D_c_coor = torch.mm(z_c_coor, torch.transpose(self.W_c[layer], 1, 0))
  147. D_c_coor = torch.mm(self.atten[layer], D_c_coor)
  148. D_expr = torch.mm(z_c_expr, torch.transpose(self.W_gc[0], 1, 0))
  149. D_expr = torch.mm(torch.transpose(self.atten_g[layer], 1, 0), D_expr)
  150. return D_c_coor, D_expr

graph_nn.py at commit 27ec12b, under MIT · at the source

Overview

Authors: Junning Feng1, Tianwei Yu2, Yanlin Zhang1
  1. Data Science and Analytics Thrust, Hong Kong University of Science and Technology (Guangzhou),Guangzhou, China
  2. School of Data Science, Chinese University of Hong Kong, Shenzhen (CUHK-Shenzhen),Shenzhen, China
Journal: Communications biology, volume 9, issue 1, article 681
Dates: received 3 August 2025; accepted 27 February 2026; published online 27 March 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s42003-026-09841-2 · PMID 41896336 · PMCID PMC13187054 · OpenAlex W7141291608
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: genetics / omics (modality), human (organism), mouse (organism), other condition (population), cellular / molecular (subfield)
Methods: Statistics, Machine learning, Connectivity, fMRI & imaging, Smoothing, state filtering, decompositions
Keywords: Bioinformatics, Biomaterials - cells
MeSH: Gene Expression Profiling*, Transcriptome*, Algorithms, Animals, Graph Neural Networks, Humans, Mice, Olfactory Bulb, Spatial Transcriptomics, Tumor Microenvironment (* major topic)
Topic: Single-cell and spatial transcriptomics (Molecular Biology, Biochemistry, Genetics and Molecular Biology), according to OpenAlex
Funding: Guangdong Provincial Project(2024QN11N085); Science, Technology and Innovation Commission of Shenzhen Municipality; henzhen Science and Technology Program: ZDSYS20230626091302006 and JCYJ20240813113536047
Citations: not cited yet (Europe PMC); 69 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repositories

Its files are read in the Code ↔ Paper reader above, with 4 matches between paragraphs and lines of code.

Seven595/HarveST

License: MIT
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Commit: 27ec12b303dd9a0ac8c9bc6accc99dd24fac48e2, 9 February 2026
Languages: Python (21), Jupyter (1)
Size: 37 files, 22 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file, environment (environment.yml, setup.py), 1 notebook
Not found: CITATION.cff, tests, continuous integration, documentation
Tools: NumPy (11 files), pandas (8 files), PyTorch (7 files), scikit-learn (6 files), Scanpy (5 files), Matplotlib (2 files), Numba (2 files), SciPy (2 files), rpy2 (1 file)
Availability: 1 check, the latest on 30 September 2026: the link answers
  • 30 September 2026: the link answers
24 files

Zenodo 18532348

License: CC-BY-4.0
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Size: 2 files
Software Heritage: not checked
Found in: “Code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
  • 30 September 2026: the link answers (HTTP 200)
At the source:

Code availability statement

The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1038/s42003-026-09841-2.

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:

  • 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 22 scripts, each with its path and the digest of its content;
  • 4 matches 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

Code and data availability statement

The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1038/s42003-026-09841-2.

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, 30 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 3 authors, 2 keywords, 10 MeSH terms, 3 funders, 64 references.

Cite

This paper

Feng, J., Yu, T., & Zhang, Y. (2026). HarveST uses a heterogeneous graph learning framework to reveal spatial transcriptomics patterns. Communications biology, 9(1), 681. https://doi.org/10.1038/s42003-026-09841-2

BibTeX

@article{feng2026harvest,
author = {Feng, Junning and Yu, Tianwei and Zhang, Yanlin},
title = {{HarveST uses a heterogeneous graph learning framework to reveal spatial transcriptomics patterns}},
journal = {Communications biology},
year = {2026},
month = mar,
volume = {9},
number = {1},
pages = {681},
publisher = {Nature Publishing Group},
issn = {2399-3642},
doi = {10.1038/s42003-026-09841-2},
url = {https://doi.org/10.1038/s42003-026-09841-2},
pmid = {41896336},
pmcid = {PMC13187054}
}

RIS

TY - JOUR
AU - Feng, Junning
AU - Yu, Tianwei
AU - Zhang, Yanlin
TI - HarveST uses a heterogeneous graph learning framework to reveal spatial transcriptomics patterns
T2 - Communications biology
J2 - Commun Biol
PY - 2026
DA - 2026/03/27
VL - 9
IS - 1
SP - 681
SN - 2399-3642
PB - Nature Publishing Group
DO - 10.1038/s42003-026-09841-2
UR - https://doi.org/10.1038/s42003-026-09841-2
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s42003-026-09841-2",
"type": "article-journal",
"title": "HarveST uses a heterogeneous graph learning framework to reveal spatial transcriptomics patterns",
"container-title": "Communications biology",
"author": [
{
"family": "Feng",
"given": "Junning"
},
{
"family": "Yu",
"given": "Tianwei"
},
{
"family": "Zhang",
"given": "Yanlin"
}
],
"container-title-short": "Commun Biol",
"volume": "9",
"issue": "1",
"page": "681",
"DOI": "10.1038/s42003-026-09841-2",
"PMID": "41896336",
"PMCID": "PMC13187054",
"ISSN": "2399-3642",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s42003-026-09841-2",
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
27
]
]
}
}

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.1093/bib/bbag298 [code]
Empowering multifaceted analysis of spatial transcriptomics data with RGAST.
Journal: Briefings in bioinformatics
In common: rpy2, Scanpy, Numba, 6 other tools, genetics / omics, mouse, 13 references
[2] doi:10.1093/bib/bbaf674 [code]
Probabilistic-graph-based spatial context-aware framework for interpretable spatial omics denoising and augmentation.
Journal: Briefings in bioinformatics
In common: rpy2, Scanpy, Numba, 5 other tools, other condition, 13 references
[3] doi:10.1038/s41467-023-36796-3 [code]
Spatially informed clustering, integration, and deconvolution of spatial transcriptomics with GraphST.
Journal: Nature communications
In common: rpy2, Scanpy, Numba, 6 other tools, genetics / omics, cellular / molecular, 12 references
[4] doi:10.1093/bib/bbaf316 [code]
TriCLFF: a multi-modal feature fusion framework using contrastive learning for spatial domain identification.
Journal: Briefings in bioinformatics
In common: rpy2, Scanpy, Numba, 6 other tools, genetics / omics, mouse, 10 references
[5] doi:10.1038/s41598-026-39703-0 [code]
Attention-guided enhanced deconvolution enables reference-free cell type estimation in spatial transcriptomics.
Journal: Scientific reports
In common: Scanpy, PyTorch, scikit-learn, 4 other tools, NCBI GEO GSE111672, genetics / omics, mouse, cellular / molecular, 7 references
[6] doi:10.1093/bib/bbaf365 [code]
Path-MGCN: a pathway activity-based multi-view graph convolutional network for determining spatial domains.
Journal: Briefings in bioinformatics
In common: rpy2, Scanpy, PyTorch, 5 other tools, genetics / omics, other condition, mouse, 9 references
[7] doi:10.1186/s12864-024-10469-x [code]
HyperGCN: an effective deep representation learning framework for the integrative analysis of spatial transcriptomics data.
Journal: BMC genomics
In common: rpy2, Scanpy, PyTorch, 5 other tools, genetics / omics, mouse, cellular / molecular, 10 references
[8] doi:10.1038/s41467-024-47152-4 [code]
Pianno: a probabilistic framework automating semantic annotation for spatial transcriptomics.
Journal: Nature communications
In common: Scanpy, Matplotlib, NCBI GEO GSE111672, genetics / omics, 11 references
[9] doi:10.1038/s41467-023-38121-4 [code]
Reconstruction of the cell pseudo-space from single-cell RNA sequencing data with scSpace.
Journal: Nature communications
In common: Scanpy, PyTorch, scikit-learn, 4 other tools, genetics / omics, other condition, cellular / molecular, 11 references
[10] doi:10.1038/s41592-026-03194-8 [code]
Beyond benchmarking: an expert-guided consensus approach to spatially aware clustering.
Journal: Nature methods
In common: rpy2, Scanpy, PyTorch, 5 other tools, genetics / omics, 10 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.

Add the badge to the code's README

OSCR: the badge of this paper

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 -->
[![OSCR](https://openscicode.org/badge/doi/10.1038/s42003-026-09841-2.svg)](https://openscicode.org/badge/doi/10.1038/s42003-026-09841-2)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1038/s42003-026-09841-2.svg
   :target: https://openscicode.org/badge/doi/10.1038/s42003-026-09841-2
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1038/s42003-026-09841-2"><img src="https://openscicode.org/badge/doi/10.1038/s42003-026-09841-2.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.