TransWikia.com

co-occurrence analysis and visualization for amplicon microbial data

Bioinformatics Asked on June 9, 2021

I 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")

dput output;

structure(list(Sample = c("PN0086A.Exp2.Soil.12.S5.L001", "PN0086A.Exp2.Soil.13.S6.L001",
"PN0086A.Exp2.Soil.14.S7.L001", "PN0086A.Exp2.Soil.15.S8.L001",
"PN0086A.Exp2.Soil.16.S9.L001", "PN0086A.Exp2.Soil.2.S1.L001",
"PN0086A.Exp2.Soil.25.S10.L001", "PN0086A.Exp2.Soil.26.S11.L001",
"PN0086A.Exp2.Soil.27.S12.L001", "PN0086A.Exp2.Soil.29.S13.L001",
"PN0086A.Exp2.Soil.30.S14.L001", "PN0086A.Exp2.Soil.32.S15.L001",
"PN0086A.Exp2.Soil.33.S16.L001", "PN0086A.Exp2.Soil.35.S17.L001",
"PN0086A.Exp2.Soil.36.S18.L001", "PN0086A.Exp2.Soil.39.S19.L001",
"PN0086A.Exp2.Soil.4.S2.L001", "PN0086A.Exp2.Soil.40.S20.L001",
"PN0086A.Exp2.Soil.42.S21.L001"), G1 = c(0.032311694, 0.035985175,
0.034322796, 0.030070684, 0.031517032, 0.033660901, 0.029227136,
0.034390475, 0.026630561, 0.0220947, 0.055526928, 0.024309091,
0.035892158, 0.040273563, 0.02016275, 0.02513636, 0.019767543,
0.024676114, 0.026866851), G2 = c(0.00839087, 0.012206947, 0.005668343,
0.00693149, 0.004260936, 0.005104718, 0.007701344, 0.00657224,
0.009340246, 0.004480314, 0.009061995, 0.007054545, 0.006707956,
0.005155473, 0.004045142, 0.009711119, 0.003914257, 0.006505354,
0.00766709), G3 = c(0.02470319, 0.029779348, 0.036199213, 0.025706413,
0.033948545, 0.058152875, 0.028313417, 0.031513982, 0.048583758,
0.029490288, 0.05614883, 0.0334, 0.033411133, 0.031826959, 0.044701179,
0.027300799, 0.04215186, 0.035678086, 0.029365596), G4 = c(0.022874411,
0.030318049, 0.009994527, 0.012818977, 0.012481764, 0.019858598,
0.04788124, 0.016403292, 0.059806534, 0.011384908, 0.016969029,
0.015163636, 0.012129454, 0.00920756, 0.007838446, 0.049724395,
0.019047931, 0.021377366, 0.045329802), G5 = c(0.006591429, 0.011032581,
0.01043757, 0.003816598, 0.007433481, 0.02052559, 0.013468453,
0.02097291, 0.016276645, 0.004725811, 0.004442154, 0.007054545,
0.005439877, 0.003300644, 0.002360978, 0.012640328, 0.00524445,
0.007076645, 0.013016968), G6 = c(0, 0, 0, 0, 0, 0, 0, 0, 0,
0.000184123, 0, 0.000272727, 0, 0, 0, 0, 0, 0, 0), G7 = c(0,
0, 0, 0.000205377, 0, 0, 0, 0, 0, 0, 0.000337604, 0, 0, 0, 0,
0, 0, 0, 0), G8 = c(9.78e-05, 8.62e-05, 7.82e-05, 0, 0, 8e-05,
0.00020173, 0, 0.00057924, 0, 0.000319835, 0.000109091, 0, 0,
0, 0, 0, 0, 0), G9 = c(0.0049778, 0.007294001, 0.004104662, 0.005168666,
0.002500984, 0.005753924, 0.003666742, 0.005844014, 0.005126274,
0.0041581, 0.004957444, 0.006527273, 0.00496205, 0.006544216,
0.002628555, 0.008369167, 0.002573161, 0.003906898, 0.002893846
), G10 = c(0.001887457, 0.001583779, 0.000794871, 0.000188263,
0.000347359, 0.001289519, 0.01384818, 0.037958782, 0.009036145,
0.000138092, 0.006378934, 0.000363636, 0.000128646, 0.001179481,
0.000566635, 0.003766125, 0, 0.00014743, 0.002381283), G11 = c(0.030756743,
0.032860714, 0.020223606, 0.033750364, 0.013500683, 0.020374405,
0.035136642, 0.024249927, 0.029888786, 0.010801853, 0.020647133,
0.023309091, 0.033135464, 0.013839876, 0.028158595, 0.078670168,
0.025349993, 0.024012679, 0.090787745), G12 = c(0.000665011,
0.000549474, 0.00231946, 0.001129576, 0, 0.000222331, 0.000771321,
0.00083746, 0.000912303, 0.000751834, 0.000746282, 0.000909091,
0.000974032, 0.00097973, 0.002203579, 0, 0.000632387, 0.000460719,
0.000662061), G13 = c(7.82e-05, 0, 0, 0, 0, 0, 0, 0.00012744,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), G14 = c(0.006327381, 0.009082486,
0.011923067, 0.006383816, 0.001621008, 0.007070123, 0.001554509,
0.00209365, 0.002432808, 0.000705803, 0.008191332, 0.005454545,
0.004925294, 0.005269616, 0.002298018, 0.003261089, 0.002289677,
0.00222988, 0.001719222), G15 = c(0.00249379, 0.005397776, 0.001720049,
0.002190693, 0.00076419, 0.002027658, 0.002468228, 0.002694436,
0.002490732, 0.00199466, 0.005739263, 0.003690909, 0.002039954,
0.000846563, 0.001983221, 0.005843987, 0.001395613, 0.001971878,
0.004452892), G16 = c(0.000352064, 0.00096966, 0.000977301, 0.001061117,
0.001366278, 0.001156121, 0, 0.001201573, 0, 0, 0.00051529, 0.000418182,
0.000551339, 0.001816781, 0.000724033, 0.000245303, 0.000272581,
0.000387004, 0), G17 = c(0.015911358, 0.02434925, 0.016575018,
0.044293074, 0.016395341, 0.009142247, 0.014678834, 0.006098893,
0.028585496, 0.021266149, 0.016098367, 0.024836364, 0.047598919,
0.033948122, 0.058158752, 0.02046117, 0.023158446, 0.034590789,
0.013945989), G18 = c(0, 0.00026935, 0, 0, 0, 0.000151185, 0,
0.000400524, 0, 0, 0, 0, 0, 0, 0, 0.00037517, 0, 0, 0), G19 = c(0.016146068,
0.015859335, 0.013577963, 0.020246795, 0.015029062, 0.003877451,
0.002824222, 0.004769881, 0.003243744, 0.01715408, 0.01169175,
0.017763636, 0.021594104, 0.014971797, 0.014354745, 0.004415457,
0.002278774, 0.002156165, 0.002989952), G20 = c(0.016527471,
0.013359766, 0.033997029, 0.011620942, 0.022022555, 0.026475166,
0.007879342, 0.011961113, 0.015118165, 0.018688434, 0.010359104,
0.026218182, 0.01036517, 0.019061932, 0.007759747, 0.01724337,
0.011513803, 0.013342425, 0.011853023), G21 = c(0.005857962,
0.011679021, 0.001915509, 0.009396019, 0.003172545, 0.006011828,
0.003939671, 0.007355083, 0.006690222, 0.005032682, 0.0167025,
0.01, 0.013140242, 0.003291132, 0.008027324, 0.007315806, 0.004841031,
0.008219229, 0.005339199), G22 = c(0.012478729, 0.006550595,
0.013017644, 0.007308015, 0.00727138, 0.008822091, 0.00862693,
0.014091174, 0.008876854, 0.009743149, 0.01297109, 0.0102, 0.008931689,
0.011423843, 0.007712527, 0.011514819, 0.006770901, 0.005676059,
0.006844854), G23 = c(0.020595771, 0.02364894, 0.002358552, 0.00239607,
0, 0.006492063, 0.061242895, 0.000564375, 0.034377896, 0, 0.015565309,
0.002654545, 0.002866962, 0.00362405, 0.001479546, 0.021961848,
0.001526451, 0.003446179, 0.065554689), G24 = c(0.006190467,
0.006572143, 0.007779313, 0.015043899, 0.015237478, 0.000809285,
0.001162915, 0.010286193, 0.00347544, 0.017230798, 0.004300005,
0.010309091, 0.015510999, 0.00818027, 0.016243527, 0.00323223,
0.012048061, 0.015590734, 0.003363696), G25 = c(0.004596397,
0.002876659, 0.004586797, 0.003097777, 0.009239747, 0, 0, 0.001092339,
0.000202734, 0.007303526, 0.002665293, 0.004181818, 0.002646426,
0.004451589, 0.000566635, 0, 0.001232064, 0.002119308, 7.47e-05
), G26 = c(0.001183328, 0.001831581, 0.000677595, 0.000581903,
0.001296807, 0.002072124, 0.001032384, 0.000983105, 0.001317771,
0.000460306, 0.001385952, 0.001763636, 0.001635639, 0.001284112,
0.00107031, 0.001327523, 4.36e-05, 0.001548016, 0.000726131),
    G27 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.000177686, 0.000181818,
    0, 0, 0, 0, 0, 0, 0), G28 = c(0, 0, 0, 0, 0, 0.000142292,
    0, 0.000327702, 0, 0, 0, 0, 0, 0, 0, 0.000101007, 0, 0, 0.000106784
    ), G29 = c(0.01246895, 0.03252672, 0.007205963, 0.018364168,
    0.012504921, 0.013233136, 0.010632365, 0.020281095, 0.010339435,
    0.027081351, 0.009168606, 0.025036364, 0.014996416, 0.018110738,
    0.010435522, 0.020490029, 0.012909416, 0.015682878, 0.008863071
    ), G30 = c(0.000733468, 0.00026935, 0.002853718, 0.000650362,
    0.003682004, 0.003272711, 0.000652656, 0.00083746, 0.000362025,
    0.004234818, 0.000248761, 0.003381818, 0.000496205, 0.005050841,
    0, 0.001399671, 0.001602774, 0.001990306, 0.000106784), G31 = c(0,
    0, 0, 0, 0, 0, 0, 0.000182057, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0), G32 = c(0.014982299, 0.010580072, 0.01777384, 0.016413083,
    0.016626913, 0.015234114, 0.009588115, 0.021318817, 0.012337813,
    0.012934606, 0.010998774, 0.017436364, 0.020491427, 0.010767519,
    0.012056726, 0.015165507, 0.018873479, 0.018668338, 0.00626822
    ), G33 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0), G34 = c(0.00430301, 0.002445699, 0.008456908, 0.002053775,
    0.005372485, 0.01041398, 0.003821006, 0.006317361, 0.002114226,
    0.006551692, 0.002221077, 0.004381818, 0.001966442, 0.002948702,
    0.00214062, 0.005165796, 0.007326966, 0.00715036, 0.001484297
    ), G35 = c(0.000176032, 6.46e-05, 0.000260613, 0.000256722,
    0.000185258, 0.000186758, 0, 0.001201573, 7.24e-05, 0.000352901,
    0.000355372, 0.000127273, 0.00018378, 0.000180727, 0.000629594,
    0, 0, 0, 7.47e-05), G36 = c(0, 0, 0, 0, 0, 0.000115612, 0,
    0.000910283, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), G37 = c(0.000215151,
    0, 0.000299706, 0.000667477, 0, 0, 0, 0, 0.000231696, 0,
    0, 0, 0.000385937, 0.000256822, 0.000724033, 0, 0, 0, 0),
    G38 = c(0.034101355, 0.035715825, 0.025722551, 0.051412826,
    0.019452099, 0.011294411, 0.012970061, 0.024523012, 0.018608086,
    0.019992635, 0.03495087, 0.029763636, 0.04939996, 0.028688018,
    0.051579494, 0.015814839, 0.027966767, 0.031439471, 0.016412699
    ), G39 = c(0.000518317, 0.000280124, 7.82e-05, 0.000136918,
    0.000162101, 0.000391302, 0.000783188, 0.002239295, 0, 0,
    0.000142149, 0, 0, 0.000532669, 0.000173138, 0.00144296,
    0, 0, 4.27e-05), G40 = c(0.004234553, 0.00470824, 0.006554429,
    0.00285817, 0.008568187, 0.01165014, 0.00862693, 0.006626857,
    0.007008804, 0.006766502, 0.003287194, 0.005145455, 0.002481025,
    0.004489637, 0.001998961, 0.010663473, 0.009856514, 0.01177598,
    0.00686621), G41 = c(0.000606333, 0, 0.001290037, 0.000564788,
    0.000625246, 0.000764818, 0.000450926, 0.001219779, 0.000463392,
    0, 0.001421489, 0.001509091, 0.001010788, 0.000437549, 0.000912911,
    0.000303022, 0.000599677, 0.00058972, 9.61e-05), G42 = c(0.000185812,
    0, 0.000599411, 0.000479214, 0.000138944, 0.000124505, 0.000225463,
    0.000728226, 0.000217215, 0.000414276, 0.001297109, 0.000672727,
    0.000551339, 0, 0.00103883, 0, 0, 0, 9.61e-05), G43 = c(0.007872553,
    0.004665144, 0.012313987, 0.007308015, 0.014195401, 0.011739072,
    0.007238552, 0.00824716, 0.007892146, 0.009881241, 0.005757032,
    0.011109091, 0.008766287, 0.012232358, 0.006925535, 0.007416813,
    0.019603995, 0.018557765, 0.008030156), G44 = c(0.014385745,
    0.010019824, 0.019272367, 0.011809204, 0.018247922, 0.029276535,
    0.015497621, 0.013708855, 0.020649907, 0.011599718, 0.010447947,
    0.016672727, 0.01325051, 0.020269949, 0.011584531, 0.015252085,
    0.017913995, 0.01758104, 0.013113074), G45 = c(0.002171064,
    0.002348733, 0.002084908, 0.001095346, 0.00261677, 0.004900173,
    0.000747588, 0.002894699, 0.001071594, 0.003436953, 0.001101654,
    0.003545455, 0.000514583, 0.00269188, 0.000928651, 0.001154368,
    0.000577871, 0.00222988, 0.001249373), G46 = c(0.007892112,
    0.000958886, 0.008756613, 0.007308015, 0.003033601, 0.000800391,
    0.004200733, 0.005570929, 0.000666126, 0.006398257, 0.010625633,
    0.006654545, 0.007075515, 0.003167477, 0.00637464, 0.000519466,
    0.001580967, 0.002045593, 0.000544598), G47 = c(0.000312946,
    0, 0, 0, 0, 0, 0.000213597, 0.002530585, 0.000101367, 0.000460306,
    0, 0, 5.51e-05, 0, 0.000188878, 0.000548325, 0.000130839,
    0, 0), G48 = c(0.000185812, 0, 0, 0, 0, 0, 0.000818787, 0.000145645,
    0.000666126, 0.000107405, 0.001972316, 0, 0, 0.000218775,
    0, 0.000447318, 0, 0, 0), G49 = c(0.002014591, 0.002337959,
    0.002058847, 0.002567218, 0.001597851, 0.003237138, 0.003097151,
    0.003040344, 0.002592099, 0.001902599, 0.00127934, 0.0014,
    0.001304835, 0.002216283, 0.003997922, 0.003867132, 0.004731999,
    0.003999042, 0.000875629), G50 = c(0.004586618, 0.006518273,
    0.001785202, 0.005545192, 0.00219994, 0.003299391, 0.008140404,
    0.004533207, 0.005734476, 0.003513671, 0.01053679, 0.005018182,
    0.00477827, 0.001930924, 0.005068232, 0.007099362, 0.002834838,
    0.004201758, 0.00413254)), row.names = c(NA, -19L), class = c("tbl_df",
"tbl", "data.frame"))

Many thanks

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP