Cytoscape input file preparation for hub/keystone genera identification

175 views
Skip to first unread message

Yogesh Gupta

unread,
Jun 2, 2021, 5:37:25 AM6/2/21
to cytoscape-helpdesk

Hello,

 am trying to learn co-occurrence analysis for microbial data. I got relative abundance at the genera level for 50 genera in 19 samples.

I understand that for network analysis first I need to do Spearman's correlation analysis and P-value calculation and after that, I need to do filtering based on these two criteria value and then I need to visualize the network in Cytoscape.

But I am not sure how I can do filtering based on spearman's correlation and P-value altogether and in which format should I save the file for Cytoscape input?

Here is the code and data file by dput command;

Rcode;

library(vegan)

library(phyloseq)

library(ggplot2)

library(magrittr)

library(dplyr)

library(reshape2)

library(RColorBrewer)

 

library(readxl)

library(corrplot)

library("PerformanceAnalytics")

library("Hmisc")

library(psych)

 

list.files()

A <-  readxl::read_excel("soil.test.wet.count.xlsx")

dput(A)

 

# Convert the first column to be row names

B <- A[, -1]

C <- data.frame(B, row.names=A$Sample)

M = as.matrix(C)

#View(M)

 

 

   

 #-------------------------------------spearman---------------------------------------------#

cor_5 <- rcorr(as.matrix(M),type=c("spearman"))

r_mat <- cor_5$r

p_mat <- cor_5$P

 

 

write.table(r_mat, "r.correlation.txt")

write.table(p_mat, "pvalues.txt")


Many thanks,

Yogesh

Scooter Morris

unread,
Jun 3, 2021, 10:01:52 AM6/3/21
to cytoscape-helpdesk
Hi Yogesh,
   At the end of the day, you want an output file that looks like this:

Species 1\tSpecies 2\tCorr\tP-Value
spp1\tspp2\t0.0\t0.0
...

The column labels can be pretty much whatever you want.  When you read it into Cytoscape (File->Import Network->From file...) you'll indicate "Species 1" as the source and "Species 2" as the target and the correlation and p-value columns as edge attributes.  Once you've done that, there are a number of tools in Cytoscape that allow you to filter the edges.

-- scooter

Yogesh Gupta

unread,
Jun 8, 2021, 4:24:43 AM6/8/21
to cytoscape...@googlegroups.com
Thank you so much. Now I am able to import the network into cytoscape.
Just some more queries;
1) How should I import edge attributes (correlation & P-value) as local or shared?
2) How can I do filtering based on cor and p-value (edge attributes)
3) How can I identify the hub microbes in a network (based network topology calculation?

Many thanks,
Yogesh




--
You received this message because you are subscribed to a topic in the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cytoscape-helpdesk/xi5Ir03dpXo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-helpd...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/bafee5b4-6f91-4439-bade-705aa73a1ca8n%40googlegroups.com.

Scooter Morris

unread,
Jun 10, 2021, 9:39:30 AM6/10/21
to cytoscape-helpdesk
Hi Yogesh,
   Glad you got the network in! 
1. I would always import your edge attributes as shared unless you know that they won't apply if you make sub-networks from your network.  In your case, I'm pretty sure they will apply. 
2. As far as filtering, go to the filters tab in the control (left) panel, add a Column Filter and choose the correlation and/or p-value columns.  You can add multiple filters and create boolean expressions -- for example, you could look for only edges that have p-value < 0.05 AND correlations > 0.6, or whatever makes sense for your data. 
3. You can calculate the topology by going to "Tools->Analyze Network".

-- scooter
Message has been deleted

Yogesh Gupta

unread,
Jun 10, 2021, 7:13:23 PM6/10/21
to cytoscape-helpdesk
Dear Scooter,

Thanks.  I am still not able to understand how to choose values in column filters for all correlations that have p-value < 0.05 AND correlations > 0.6 (positive and negative). like using add condition I have added p-value and or edge but not sure what value to put (between and inclusive section)? 
For cor edge should I put -0.6 and 0.6 and for the P-value edge should I put 0.05  in the last column ?
 
One more query;

How can I color modules and hub microbes in the network?

Many thanks
Yogesh

Scooter Morris

unread,
Jun 17, 2021, 11:58:07 AM6/17/21
to cytoscape-helpdesk
Hi Yogesh,
If you go into the filters tab, you just click the "+" button twice and set up a filter for p-value and one for cor.  Then make sure to set the AND rather than OR at the top.  As far as your correlations, you have to decide if you want to select both positive and negative correlations.  I'm not really familiar enough with your data.

Once you've done the simple network calculations, there will be columns in the node table that have node degree.  You can use this to color your nodes.  See an example here: https://www.youtube.com/watch?v=iGpxX0Kd4Z0

-- scooter
Reply all
Reply to author
Forward
0 new messages