# Clarification on subgraph function and sample-specific information

**URL:** <https://igraph.discourse.group/t/clarification-on-subgraph-function-and-sample-specific-information/2206>\
**Category:** Usage\
**Tags:** R\
**Created:** [21 September 2025 05:55 UTC](https://igraph.discourse.group/t/clarification-on-subgraph-function-and-sample-specific-information/2206 "2025-09-21T05:55:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![H\_Charlie](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@H\_Charlie](https://igraph.discourse.group/u/H_Charlie)\
**Post date:** [21 September 2025 05:55 UTC](https://igraph.discourse.group/t/clarification-on-subgraph-function-and-sample-specific-information/2206/1 "2025-09-21T05:55:58Z")

</div>

Hello, thank you for the great tool! I have a question regarding the use of the subgraph function in building single-sample subnetworks.

From what I understand, the current implementation takes the global network and then extracts the subgraph based on which microbes are present in each sample. This means that:

- The subgraph reflects only presence/absence of nodes for each sample.

- The abundance information is not incorporated into the subnetwork structure.

- Edge weights in the subgraph are inherited from the global network, rather than recalculated for each sample.

Could you please clarify:

1. Is this interpretation correct?

2. If so, is there a recommended way to integrate abundance information into sample-specific subnetworks (e.g., using node attributes or recalculating edge weights)?

Thanks a lot for your help!

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [23 September 2025 10:00 UTC](https://igraph.discourse.group/t/clarification-on-subgraph-function-and-sample-specific-information/2206/2 "2025-09-23T10:00:12Z")

</div>

I’m sorry, I have some trouble following your terminology.

First, you should use `induced_subgraph()` instead of `subgraph()`. The latter name will be repurposed in the future. We will make the documentation clearer about this.

This function computes what is called an induced subgraph: it keeps only the vertices you specify and the edges between them. It also keeps all attributes of these vertices and edges. The documentation says,

> creates a subgraph of a graph, containing only the specified vertices and all the edges among them.

> [@H\_Charlie](#):
>
> single-sample subnetworks

I am not sure what this means.

> [@H\_Charlie](#):
>
> The subgraph reflects only presence/absence of nodes for each sample.

Again, I am not sure what you mean.

> [@H\_Charlie](#):
>
> The abundance information is not incorporated into the subnetwork structure.

I am not sure what you mean by “abundance”. I assume this has to do with your biological dataset. Can you phrase the question in terms of graphs?

> [@H\_Charlie](#):
>
> Edge weights in the subgraph are inherited from the global network

Yes.

> [@H\_Charlie](#):
>
> If so, is there a recommended way to integrate abundance information into sample-specific subnetworks (e.g., using node attributes or recalculating edge weights)?

I am not sure what you mean by “abundance”, and how this is represented in the networks you built.

Vertex attributes are preserved in the subgraph.

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [23 September 2025 10:08 UTC](https://igraph.discourse.group/t/clarification-on-subgraph-function-and-sample-specific-information/2206/3 "2025-09-23T10:08:54Z")

</div>

I understand that you are analysing some sort of biological dataset where a network representation is useful, but you did not describe what your network is (what do the vertices and edges represent? what attributes?). Thus we are having a bit of of miscommunication. If you can clarify this, perhaps I can answer. At the moment I am overwhelmed and I need a very clearly stated question to be able to answer. 🙂

---

<div class="post-metadata">

**Author:** ![H\_Charlie](https://avatars.discourse-cdn.com/v4/letter/h/e56c9b/32.png) [@H\_Charlie](https://igraph.discourse.group/u/H_Charlie)\
**Post date:** [25 September 2025 06:17 UTC](https://igraph.discourse.group/t/clarification-on-subgraph-function-and-sample-specific-information/2206/4 "2025-09-25T06:17:29Z")

</div>

I’m so sorry that I haven’t clearly clarified my target! I want to build microbial sample-specific networks, which are able to reflect the microbial structure of each sample, and I found some tutorials say that subgraph() is capable to do this. Now with your clear explanation I understand how this function works!! Thanks a lot!!
