Create a correlation heatmap correlating individual ASVs to environmental variables?

I am interested to see which specific ASVs in my microbial abundance dataset are correlated with different environmental variables (e.g., temperature, depth, salinity, oxygen etc).

I am able to create a correlation heatmap using corrplot of what individual ASVs are positively/negatively correlated with each other, but I am not sure how to take it one step further, and plot ASVs to environmental variables.

Can anyone recommend an R package or other resources? I would like to create something like Figure 3 of this article here.

https://www.nature.com/articles/ismej201344#Sec2

Thank you.

Haw a look at Create a correlation heatmap for some hints assuming I understood the question.

Otherwise can you supply more info?

See FAQ Asking Questions

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here between
```

```

Hi there,

Here is my data and my code:

dput(df)
structure(list(Station = c("E1", "E1", "E1", "E2", "E2", "E2",
"W", "W", "W", "W", "NW", "NW", "NW", "NW", "SW1", "SW1", "SW1",
"SW2", "SW2", "SW2", "E1", "E1", "E1", "E2", "E2", "E2", "W",
"W", "W", "W", "NW", "NW", "NW", "SW1", "SW1", "SW1", "SW1",
"SW1", "SW2", "SW2", "SW2", "SW2", "SW2", "E1", "E1", "E1", "E1",
"E1", "E2", "E2", "E2", "E2", "E2", "NW", "NW", "NW", "NW", "NW"
), Cluster = c("Surface", "Surface", "Surface", "Surface", "Surface",
"Surface", "Surface", "Surface", "Surface", "Surface", "Surface",
"Surface", "Surface", "Surface", "Surface", "Surface", "Surface",
"Surface", "Surface", "Surface", "Midwater", "Midwater", "Midwater",
"Midwater", "Midwater", "Midwater", "Midwater", "Midwater", "Midwater",
"Midwater", "Midwater", "Midwater", "Midwater", "Midwater", "Midwater",
"Midwater", "Midwater", "Midwater", "Midwater", "Midwater", "Midwater",
"Midwater", "Midwater", "Deep", "Deep", "Deep", "Deep", "Deep",
"Deep", "Deep", "Deep", "Deep", "Deep", "Deep", "Deep", "Deep",
"Deep", "Deep"), Salinity = c(34.091, 34.0489, 33.8147, 33.4791,
33.0551, 34.0191, 34.0061, 33.7955, 33.4601, 33.1693, 33.46,
33.3959, 33.3228, 33.2427, 32.9601, 32.6426, 32.3005, 31.9678,
32.609, 32.3597, 32.082, 32.437, 32.4362, 32.3918, 32.1102, 32.5639,
32.3043, 31.9692, 32.8157, 32.815, 32.6033, 32.4381, 32.1326,
32.8307, 32.8304, 32.5118, 32.3182, 32.0927, 30.857, 30.1324,
30.1305, 31.4171, 30.2478, 30.226, 31.5428, 30.8087, 30.4193,
30.3979, 31.4589, 30.9011, 29.8362, 29.7369, 31.4363, 30.4789,
30.4203, 31.4572, 30.6586, 30.6256), Temp = c(0.3728, 0.2365,
-0.4855, -1.1156, -1.146, 0.1299, 0.0998, -0.4797, -1.131, -1.1116,
-0.7143, -0.76, -0.8318, -0.909, -1.0809, -1.4229, -1.4735, -1.5223,
-1.4464, -1.4182, -1.541, -1.271, -1.2708, -1.283, -1.3967, -1.2499,
-1.3278, -1.4253, -1.0811, -1.0809, -1.1969, -1.2047, -1.0891,
-1.085, -1.085, -1.2869, -1.3308, -1.0652, -0.8243, 0.0925, 0.1058,
-1.2352, 0.2925, 0.3529, -1.2408, -0.2556, 0.3121, 0.3494, -1.2253,
-0.7886, 0.417, 0.6123, -0.6249, 0.4287, 0.5423, -0.8556, 0.0956,
0.2918), O2 = c(5.70661664, 5.77084574, 6.1663775, 6.61408918,
6.68927208, 5.78807308, 5.80798908, 6.12415558, 6.60024756, 6.6100064,
6.18918132, 6.26774994, 6.36633414, 6.46780616, 6.68628468, 7.0242592,
7.29919958, 7.99775328, 7.01738818, 7.19722966, 7.72659694, 7.1417636,
7.1487342, 7.17920568, 7.49547176, 6.9968747, 7.20559438, 7.70219984,
6.71894692, 6.70799312, 6.94519268, 7.12772282, 7.38304594, 6.68160442,
6.68827628, 7.03999284, 7.24124402, 7.44438722, 8.85772616, 8.48390284,
8.48888184, 8.98359528, 8.50023396, 8.46747214, 8.39109428, 8.7225961,
8.5254277, 8.5328962, 8.4363036, 8.82605972, 8.65627582, 8.55141808,
7.93033762, 8.3586312, 8.41011406, 8.12949762, 8.36022448, 8.35783456
), Chl = c(87.1111, 83, 80.5556, 81.8889, 85.3333, 85.2222, 82.8889,
81, 82, 87, 94.7778, 92, 90, 87, 98.3333, 86.6667, 98, 509.6667,
91, 106.6667, 225.2222, 151.3333, 157, 162.2222, 205.3333, 110,
126.4444, 231.5556, 131.1111, 131.7778, 106, 148.4444, 219.8889,
132.7778, 134.7778, 111.3333, 131, 245.1111, 222, 201.6667, 147.7778,
637.3333, 321.2222, 225.4444, 644, 1310.7778, 983.8889, 1072.3333,
360.1111, 560.7778, 597.7778, 520, 548.5556, 1404.2222, 641.1111,
668.6667, 1158.6667, 310.7778), ASV1277 = c(2.036617262, 1.909595648,
1.889534884, 2.169859843, 1.800725235, 1.837677334, 1.585478288,
0.761679079, 0.576960174, 0.665310387, 4.502099306, 0.88482843,
1.134101466, 0.619030102, 0.935761858, 0.584213398, 0.702289464,
1.408987053, 0.688361527, 1.792719789, 5.055231126, 1.93603806,
4.949866734, 5.415207998, 7.658651238, 8.98690424, 7.424672834,
4.999874122, 7.732581555, 7.314309884, 8.134705332, 8.949416342,
11.9672155, 5.200745924, 3.65929295, 5.992807186, 7.806855879,
3.846084786, 5.440250887, 6.019913942, 9.528439475, 10.22776184,
3.228053321, 2.145277472, 2.084863049, 2.2582038, 4.029872819,
4.488122298, 3.402646503, 2.854308826, 3.367244394, 5.403389478,
4.101138037, 4.2216531, 3.986298209, 4.149309198, 4.347394171,
4.918103448), ASV577 = c(5.60418483, 6.870057765, 6.329281184,
3.45891732, 4.685182133, 4.618937644, 10.53761166, 4.815504401,
3.331988847, 2.430307362, 9.084063527, 5.786154473, 5.275381553,
4.571689521, 4.289704232, 2.372163195, 2.173084255, 8.195374193,
6.425854859, 7.547109139, 0.102019278, 2.440421127, 5.140246224,
0.160847762, 0.242270837, 0.994758451, 1.522325005, 2.009012865,
1.587461404, 7.350564208, 0.576239476, 1.471421556, 3.721680496,
0.569005913, 0.520608191, 0.831330309, 1.175820125, 5.185570898,
0.572772611, 0.436526909, 1.01010101, 1.93687231, 5.601056803,
0.017952113, 0.131277396, 0.015112263, 0, 0.022284619, 0, 0.022232483,
0.049558789, 0.036427345, 0.039726123, 0.008156208, 0.017748434,
0.061437948, 0.060846134, 0.242816092), ASV2550 = c(6.988666085,
5.103471482, 5.162715192, 7.232866144, 7.664414043, 5.28208512,
8.105738857, 8.124576845, 7.479438121, 7.915910632, 6.017250821,
7.351989066, 5.613199011, 6.390724697, 4.78861808, 3.845536545,
3.888677087, 4.421373311, 3.954636975, 3.284777156, 0.323647365,
2.590194265, 4.006430596, 0.365849812, 0.470077744, 1.247910683,
2.044334377, 2.66861358, 1.496845214, 3.151105002, 0.838166511,
1.055872464, 1.579643381, 1.177858179, 1.503561561, 1.158440713,
1.208993734, 3.740146877, 1.326306161, 1.089238572, 0.911071499,
1.020444763, 3.674792843, 0.320894015, 0.551810071, 0.220207254,
0.166370896, 0.352096983, 0, 0.584885332, 0.3042359, 0.154382557,
0.320145818, 0.311567134, 0.356743517, 0.460035364, 0.386186686,
0.962643678), ASV3327 = c(0.373147341, 0.098143682, 0.079281184,
0.363250611, 0.164826108, 0.098977235, 0.117890664, 0.064883773,
0.045595637, 0.033907003, 0.670865279, 0.069539362, 0.048259637,
0.019027565, 0.100260199, 0, 0.020065413, 0.32268409, 0.125625979,
0.302270242, 5.646239358, 1.592440862, 2.546854508, 4.904279812,
7.161453625, 5.632637165, 5.897491927, 4.644898165, 7.574842261,
2.213024366, 5.833489242, 7.064334555, 5.08334181, 6.56030347,
4.606536734, 6.757269622, 5.764835975, 2.73822563, 5.891064312,
6.633130314, 5.662687481, 5.665351506, 1.537168248, 2.071225007,
2.189439957, 2.357512953, 4.144483881, 4.962784686, 4.36357908,
2.818394815, 2.900565796, 3.547329529, 3.862781296, 5.322741138,
5.283708713, 4.431024665, 4.810569843, 4.498563218), ASV3117 = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.590937874,
0.06827893, 0, 1.908096004, 1.598264328, 0.296967042, 0.997887683,
0.543792956, 1.040408108, 0.359522047, 2.016838167, 1.180537192,
0.604536933, 1.308554215, 0.877704061, 1.246995464, 1.37117582,
0.30883594, 1.358973801, 1.33868252, 1.901366607, 1.12446198,
0.235378888, 7.512959181, 6.630621009, 4.112694301, 3.970718722,
3.23349824, 6.395715186, 5.609426573, 5.006814334, 3.783239952,
3.306615568, 3.973704386, 4.03954351, 3.665298049, 3.283207709,
2.045977011), ASV3517 = c(1.680906713, 0.970220403, 1.168453639,
4.481162402, 1.887258942, 1.530847905, 1.606638151, 2.747686752,
2.09213826, 1.711845457, 1.341730559, 1.158190058, 1.179344875,
1.605926452, 4.284929937, 2.766988733, 2.781066276, 2.637591694,
1.708857492, 1.287864171, 1.959473721, 6.096647725, 3.079917079,
2.70602706, 1.632616163, 4.490206579, 4.423725933, 4.994839002,
2.429856357, 3.669239717, 2.289990645, 2.311964036, 2.287358493,
5.133804052, 7.341139324, 4.263278694, 3.208625138, 6.354479019,
6.522638674, 5.182198017, 2.25607231, 2.291965567, 6.057403627,
1.775015147, 1.619829562, 1.893350604, 0.998225377, 1.501983331,
1.937618147, 1.467343902, 1.227956664, 0.810074763, 1.675507676,
1.313149438, 1.201568962, 1.73974286, 1.840285108, 3.649425287
), ASV908 = c(0.0836966, 0, 0, 0, 0, 0.049488618, 0, 0, 0, 0.007331244,
0.031945966, 0, 0, 0, 0, 0, 0, 0.032067984, 0, 0, 2.508267079,
0.544028897, 0, 1.554861702, 1.079370819, 0.18012755, 0.759948527,
0.926462073, 0.865888039, 0.241695494, 1.627689429, 0.887763968,
0.158400302, 1.214516823, 1.103238296, 1.087958361, 0.860670844,
0.326791518, 0.916871747, 1.19525225, 0.777831794, 0.539813486,
0.228173412, 6.561497206, 6.917651247, 6.176597582, 4.266489204,
4.156081473, 3.528670447, 3.890684589, 3.803637064, 2.603687835,
2.909354334, 4.187397028, 4.68736134, 3.603860101, 3.485614236,
2.390804598), ASV655 = c(0.742807323, 1.245022713, 1.351555421,
0.131798894, 0.766441404, 0.960079182, 0.42924293, 2.665876777,
3.065429739, 3.098366965, 0.415297554, 3.301920725, 5.462387646,
6.351401063, 1.845265093, 5.341379642, 5.895218412, 1.398965808,
3.006418971, 3.281561515, 0, 0.048456015, 0.160764902, 0, 0,
0, 0.036419259, 0.02014048, 0.016780776, 0.055892083, 0, 0.011333157,
0.059581765, 0.011156979, 0.037589039, 0.010843439, 0.029487652,
0.179555779, 0.030489797, 0.008314798, 0.014404292, 0.016140603,
0.360273808, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.007183908
), ASV1146 = c(0.163905841, 0, 0, 0.070721358, 0, 0, 0.068013845,
0.019747235, 0, 0.013746082, 0.474625776, 0.045560271, 0.039210955,
0.013953547, 0.042968657, 0, 0.026085037, 0.106225197, 0.046464403,
0.07235192, 5.32083304, 0.411876129, 0.406142912, 4.882202668,
5.492677635, 2.245914675, 2.406099012, 1.734598827, 3.46690831,
1.814226801, 4.942937325, 4.036492766, 3.633034456, 2.609139159,
1.738493055, 3.140982777, 3.781791375, 0.922916704, 2.844262474,
2.673207641, 5.180143683, 3.99748924, 0.694127537, 3.040639095,
3.248559286, 3.424006908, 5.482845312, 5.134376254, 3.638941399,
2.637114566, 4.000495588, 5.441551458, 4.416610193, 4.358677389,
4.16555739, 4.164294063, 4.418174368, 3.745689655), ASV1208 = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.89354816,
0.063873838, 0, 0.605544517, 0.439341891, 0.084384077, 0.59970379,
0.463231036, 0.570546382, 0.066466261, 0.808231993, 0.485436893,
0.097365323, 0.985001833, 0.61646024, 0.787956554, 0.60081091,
0.177760221, 0.866781366, 0.873053818, 0.588775455, 0.358680057,
0.139305872, 4.624913044, 3.991722849, 2.01208981, 1.508429459,
1.421758702, 5.482041588, 3.847929814, 2.672044713, 1.427604989,
1.423129951, 3.376669984, 2.548675079, 2.091887194, 1.685065379,
1.012931034), ASV997 = c(0.578901482, 0, 0.005662942, 0.141442716,
0, 0, 0.027205538, 0, 0.008768392, 0, 0.086710478, 0, 0, 0, 0.17903607,
0, 0, 0.132280435, 0.027534461, 0.03697987, 5.322591993, 3.275186115,
0.549985193, 3.92342385, 4.559754113, 3.089755448, 3.115060577,
2.66609602, 2.946704256, 1.249263584, 3.681945744, 3.490612368,
1.146585674, 3.168581948, 2.943221757, 3.325321237, 2.729450792,
1.115041388, 2.44353943, 3.024507868, 3.311186734, 2.62553802,
0.742164045, 1.169131342, 1.622054602, 3.309585492, 5.113132209,
5.343851674, 0, 1.178321619, 2.387081676, 4.400770178, 4.439978501,
2.893822488, 3.404149584, 3.335631013, 3.547702127, 3.737068966
), ASV915 = c(2.493461203, 4.237002972, 3.779069767, 2.140928379,
1.850173067, 2.144506763, 2.929129574, 1.122771383, 1.15216667,
1.088689723, 3.755932822, 1.611394864, 1.254750558, 1.108672764,
1.577904562, 0.584213398, 0.692256757, 2.110474205, 2.194152369,
2.665766287, 0.728206571, 3.222325008, 3.596057029, 0.879931876,
0.952811427, 2.794411178, 1.981207663, 2.499937061, 1.567324473,
4.199459206, 2.013096352, 2.011635375, 3.871361516, 1.028035894,
0.984832823, 1.362658811, 1.656837449, 1.923042393, 1.206524817,
1.134969963, 1.798736023, 3.107962697, 2.159241023, 0.065076409,
0.091226665, 0.233160622, 0.369713103, 0.572714712, 0.236294896,
0.047885349, 0.22714445, 0.451005221, 0.572523544, 0.2120614,
0.351418987, 0.430065634, 0.522780047, 1.100574713), ASV1993 = c(0.58238884,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.152777446, 0, 0, 0.092195454,
0, 0, 2.689439246, 2.198141051, 0.363836358, 4.150503043, 2.46248418,
1.380977882, 1.794255469, 2.144961104, 1.600886025, 1.024184655,
2.596819457, 1.537531638, 0.527516603, 2.45772302, 2.678219031,
2.325917626, 1.894581644, 0.915734473, 2.879107956, 2.708545534,
2.30828787, 1.850789096, 0.787798727, 1.772771133, 1.83120842,
2.562607945, 2.037119196, 2.576101974, 0.897920605, 1.814512681,
2.132404565, 1.751981821, 2.66165027, 1.999902126, 2.529151802,
2.698774238, 2.654878246, 3.137931034), ASV1104 = c(0.906713165,
1.090796927, 1.006115977, 1.931978912, 1.804845888, 2.342461234,
0.562247782, 1.447190251, 1.599354646, 2.139806822, 0.191675794,
0.3189219, 0.609277915, 0.905712075, 1.998042539, 2.68673964,
3.98298453, 1.160460176, 0.774406718, 0.701009711, 0.019348484,
0.389850667, 0.609214367, 0.069385309, 0.047007774, 0.149294906,
0.223371452, 0.266861358, 0.114109276, 0.294566383, 0.059869036,
0.096331835, 0.114803889, 0.175323951, 0.358975323, 0.258435292,
0.202727608, 0.97498788, 0.252629745, 0.139272871, 0.093627901,
0.120157819, 0.999159361, 0, 0, 0.030224525, 0, 0.037883853,
0.141776938, 0, 0.016519596, 0, 0, 0, 0, 0.028471244, 0, 0.058908046
), ASV1926 = c(2.378378378, 3.897706242, 3.49025974, 3.799665681,
2.814405802, 3.309138898, 1.553738494, 1.926765967, 1.573049471,
1.113432672, 0.52026287, 1.15339424, 1.56542197, 1.704869788,
3.423169655, 1.604981864, 1.825952605, 3.461338037, 3.522690117,
2.805646665, 0.121367762, 1.224615656, 1.861488345, 0.066231432,
0.061471705, 0.321308602, 0.461310608, 0.639460235, 0.27184857,
0.664662608, 0.097287184, 0.166219637, 0.244139915, 0.328333944,
0.479260248, 0.408436195, 0.455215628, 2.239060564, 0.411612257,
0.272309643, 0.171050973, 0.243902439, 2.702053561, 0.058344366,
0.053400975, 0.023747841, 0, 0.031198467, 0, 0.015391719, 0.033039193,
0.026019532, 0.098146893, 0.019574898, 0.049695614, 0.022477298,
0.038494493, 0.081896552), ASV1484 = c(2.427201395, 3.836015927,
2.674796134, 2.092709271, 1.953189385, 2.791158034, 2.475703943,
1.156623787, 1.167949775, 1.460750353, 2.824936108, 2.114955759,
2.132472703, 1.169560971, 1.16254088, 0.905209771, 1.117643518,
2.661642682, 2.911769261, 2.660942826, 0.049250686, 1.044006872,
1.916486864, 0.110385719, 0.135599349, 0.438148094, 0.34234103,
0.639460235, 0.392670157, 1.596700857, 0.265668849, 0.508103207,
1.055033206, 0.164166972, 0.171030128, 0.206025338, 0.469959454,
1.053992423, 0.158982512, 0.160059867, 0.383514287, 0.772955524,
1.433889756, 0, 0.033375609, 0, 0, 0.051254624, 0, 0, 0.026156028,
0.062446877, 0.035052462, 0, 0.02129812, 0.049450055, 0.01738461,
0.146551724), ASV1107 = c(0.073234525, 0, 0.283147085, 0.311816896,
0, 0.244143847, 0.111844989, 0.741931844, 0, 0, 0.093556042,
0.055151908, 0, 0, 1.675777613, 1.303245273, 0.581896984, 0.571210967,
0.344180764, 0.038587691, 0, 0.0572662, 0, 0, 0, 0, 0.12868138,
0.143500919, 0, 0.628408284, 0.329279701, 0.358883306, 0.736779388,
1.107728599, 2.922547785, 0.757233477, 0.83302617, 0.648196362,
0.973495655, 0.750410543, 0.081024145, 0.141678623, 1.405067852,
0.341090142, 0.691987629, 0.179188256, 0, 0, 3.827977316, 1.024404426,
0, 0.104078128, 0, 0.177805328, 0.308822746, 0.158839572, 0.076988986,
0.262931034), ASV2953 = c(0.64516129, 0.46828557, 0.471911809,
1.221550727, 0.482116367, 0.303530188, 0.879645723, 0.299029564,
0.261298073, 0.250178699, 0.536235853, 0.179843177, 0.153827592,
0.192812655, 0.895180349, 0.086669021, 0.190621426, 0.958031026,
0.337297148, 0.352112676, 0.617392528, 3.817012466, 2.140711596,
0.816854322, 0.797324173, 2.555863882, 2.085609537, 2.65350822,
1.167942006, 2.990981737, 1.11131899, 1.512976465, 1.546219464,
0.835179548, 1.212246509, 1.151211754, 1.113158865, 1.655504282,
1.062787203, 0.970752697, 1.013702083, 1.533357245, 1.947880389,
0.069564437, 0.11125203, 0.325993092, 0.310559006, 0.494718545,
0, 0.078668787, 0.162442698, 0.169994276, 0.602902344, 0.179436569,
0.269776192, 0.386609524, 0.38370317, 0.909482759), ASV1109 = c(0.491717524,
0.173854523, 0.151011779, 1.488363122, 0.354376133, 0.191355988,
0.67560419, 0.217219589, 0.224470828, 0.120049119, 0.570463673,
0.165455723, 0.114616638, 0.068499233, 0.806855888, 0.134818477,
0.114372856, 0.571210967, 0.490457588, 0.455013184, 0.381692816,
3.103387516, 3.731438, 0.375311445, 0.828060025, 3.323434432,
2.65374997, 2.817149619, 2.369445563, 3.651112555, 1.35453695,
2.406407011, 3.066281081, 1.925375751, 1.727216344, 2.184952921,
2.211573903, 2.520963137, 1.931746412, 2.037125574, 1.546660905,
2.485652798, 2.464272847, 0.089760564, 0.068976259, 0.103626943,
0, 0.191647725, 0, 0, 0, 0, 0.259388218, 0.048937246, 0.14198747,
0.196301735, 0.286846059, 0.67816092), ASV874 = c(0.034873583,
0, 0.035865297, 0.118940465, 0.037085874, 0.0560871, 0.099753639,
0.033852404, 0, 0.005498433, 1.37139467, 0, 0.027146046, 0.007611026,
0, 0, 0, 0.12025494, 0.048185307, 0.18329153, 0.262084008, 0.220254614,
0.621906333, 0.157693885, 0.565901284, 0.761079467, 0.966324326,
0.604214395, 1.167942006, 1.376153718, 0.879326473, 1.716973292,
3.355470623, 0.824022569, 0.571353393, 1.042777366, 1.06524143,
0.684107518, 0.855892153, 0.798220633, 1.173949837, 1.635581062,
0.482766903, 0.170545071, 0.215828939, 0.084196891, 0.269890565,
0.307527744, 0, 0.138525473, 0.141793202, 0.24111433, 0.299114341,
0.384973003, 0.378041638, 0.43156412, 0.289329575, 0.531609195
), ASV909 = c(0, 0, 0, 0.106082037, 0, 0, 0.077082357, 0, 0,
0, 0.873950347, 0.035968635, 0, 0, 0.023871476, 0, 0, 0.084178458,
0, 0.114155251, 0.300780975, 0.231267345, 0.300376528, 0.148232252,
0.58759718, 0.868182335, 0.830359094, 0.465748596, 1.567324473,
1.364068944, 0.890551918, 1.822749424, 3.352564196, 0.985001833,
0.494295863, 1.312056097, 1.262440103, 0.658969709, 0.83629157,
0.972831397, 1.45483354, 1.929698709, 0.360273808, 0, 0, 0, 0.110913931,
0.211703882, 0, 0, 0, 0, 0.271072372, 0.146811738, 0.16328559,
0.253244223, 0.217307621, 0.627873563), ASV2816 = c(1.597210113,
2.551735741, 2.646481426, 2.292014916, 1.450469754, 1.177829099,
0.547133594, 0.406228842, 0.578713852, 0.664393981, 0.40845199,
0.522744167, 0.811365144, 0.775056131, 1.059893533, 0.561743652,
0.493609166, 1.056239227, 0.504224819, 0.713872275, 0.539998593,
2.971234747, 2.952997419, 0.722237992, 0.663532815, 2.330298752,
1.24068274, 1.480325269, 0.953148074, 1.515128627, 0.550046773,
0.91798572, 0.831238283, 0.67260643, 0.85703009, 0.82590859,
0.720604497, 1.285619378, 0.707798854, 0.602822874, 0.73281838,
0.841104735, 1.090428726, 0.065076409, 0, 0.123056995, 0.177462289,
0.31421313, 0.236294896, 0.041044585, 0.068831652, 0.216829433,
0.455682004, 0.104399458, 0.118914506, 0.235262385, 0.242142777,
0.679597701), ASV2342 = c(1.820401046, 0.93096293, 0.664451827,
0.630063006, 1.32272952, 0.550973276, 0.370297598, 0.564206725,
0.406853375, 0.338153626, 0.734757211, 1.52267223, 1.131085239,
0.662159248, 0.5466568, 0.773601258, 0.870838935, 0.615304445,
0.943055293, 0.797478938, 1.862731302, 1.427249901, 0.8334391,
2.29602296, 1.055866932, 0.697791409, 1.218831185, 1.32423655,
0.741710297, 0.74019245, 0.901777362, 0.61199048, 0.318253818,
1.686297636, 2.24406563, 1.209043428, 1.041282713, 1.001921247,
1.962236209, 1.569418172, 0.777831794, 0.668938307, 1.11925063,
0.724816552, 0.985692989, 1.379533679, 0.850340136, 1.497526407,
0.740390674, 1.108203786, 0.903071268, 0.862113827, 1.343677704,
0.680227721, 0.667341107, 1.012976893, 1.149867753, 1.623563218
), ASV1883 = c(0, 0.075710841, 0.035865297, 0.228237109, 0.618097907,
0.903992082, 0.327977873, 0.956330399, 1.099556319, 1.419512106,
0.162011683, 0.110303815, 0.202087229, 0.296830008, 1.107636485,
1.290405418, 2.255352449, 0.497053754, 0.602316337, 0.274937295,
0.079152888, 0.090304392, 0.1988408, 0.04100041, 0.016271922,
0.073024682, 0.165100639, 0.269378918, 0.077191569, 0.178250427,
0.074836296, 0.107664992, 0.085739613, 0.350647902, 0.535643806,
0.247591853, 0.208256543, 0.411182734, 0.461702637, 0.297254038,
0.133239705, 0.12374462, 0.686922061, 0.047124296, 0.053400975,
0.056131261, 0.044365572, 0.040112314, 0.141776938, 0.088929933,
0.063325119, 0.01908099, 0.046736616, 0.065249662, 0.053245301,
0.058440975, 0.054637345, 0.143678161), ASV2564 = c(0.02092415,
0, 0, 0, 0, 0, 0.009068513, 0, 0, 0, 0.052482658, 0, 0, 0, 0,
0, 0, 0.010021245, 0, 0, 0.951593611, 0.176203691, 0.088843762,
0.788469423, 1.355993491, 0.31644029, 0.466166509, 0.274414038,
0.583971003, 0.20544117, 0.883068288, 0.657323108, 0.424338424,
0.45106071, 0.381528746, 0.585545696, 0.558422411, 0.134666834,
0.511793018, 0.594508076, 0.78503394, 0.954088953, 0.100876666,
0.63056796, 0.743163563, 0.712435233, 1.379029873, 1.176627891,
2.252678009, 1.150958562, 1.161878278, 1.219448733, 1.09363681,
0.794414629, 0.867898408, 0.834656996, 0.918900796, 0.635057471
), ASV2894 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0.710617041, 0.396458306, 0, 0.747469013, 0.343518351,
0.084384077, 0.415179547, 0.543792956, 0.369177071, 0.138974909,
0.58746492, 0.292773224, 0.094458896, 0.500470187, 0.55819723,
0.392171037, 0.363066716, 0.242400302, 0.529215759, 0.534225788,
0.372711068, 0.344332855, 0.216164285, 1.451877118, 1.590904034,
2.204231434, 0.728334812, 0.978294781, 1.622558286, 1.434850273,
1.365619967, 0.68865028, 1.296941088, 0.774839731, 0.961965107,
1.144843708, 1.19705455, 1.021551724), ASV2999 = c(1.659982563,
1.946049016, 2.195333736, 1.948051948, 0.82000989, 0.828109535,
0.395991717, 0.239787858, 0.171860477, 0.069646817, 0.15060241,
0.251780447, 0.22320082, 0.16490556, 0.205294693, 0.121978622,
0.070228946, 0.32268409, 0.404412397, 0.200977555, 0.056286498,
1.310514955, 1.231120701, 0.075693065, 0.128367384, 0.561478669,
0.305921771, 0.488406636, 0.308766277, 0.419945921, 0.089803555,
0.151108761, 0.135148882, 0.255016656, 0.32702464, 0.258435292,
0.235901216, 0.565600704, 0.28965307, 0.228656952, 0.154846144,
0.208034433, 0.595652696, 0.017952113, 0.07342634, 0.023747841,
0, 0.004456924, 0.157529931, 0, 0.038545725, 0.012142448, 0.170588648,
0.032624831, 0, 0.028471244, 0.031043946, 0.07183908), ASV3553 = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.765144586,
0.200431699, 0, 0.709622481, 0.207919002, 0, 0.369048486, 0.395256917,
0.372533226, 0.128400731, 0.478952292, 0.262551471, 0.058128551,
0.328333944, 0.259364369, 0.318074205, 0.302248433, 0.159804643,
0.322320709, 0.399110317, 0.28268424, 0.25107604, 0.136904047,
2.021856697, 1.931335247, 1.988341969, 1.249630287, 1.25685252,
1.197227473, 1.224496776, 1.24447626, 0.830890388, 0.869301054,
1.303361989, 1.235290986, 1.111877004, 0.980988688, 0.646551724
), ASV3133 = c(0.523103749, 0.443048623, 0.481350045, 1.748746303,
0.556288116, 0.362916529, 0.154164714, 0.090273076, 0.078915525,
0.052235113, 0.063891931, 0.04795818, 0.066357001, 0.074841754,
0.544269652, 0.192597824, 0.202660674, 0.316671343, 0.123905075,
0.139880378, 0.198761697, 2.002114444, 1.988408004, 0.346926546,
0.303742542, 1.397205589, 0.548716828, 0.692328995, 0.372533226,
0.483390988, 0.299345182, 0.217218843, 0.232514205, 0.3889004,
0.520608191, 0.375905879, 0.350165868, 0.54405401, 0.42250147,
0.347142827, 0.304290679, 0.356886657, 0.530803411, 0.100980634,
0.100126827, 0.250431779, 0.14418811, 0.191647725, 0, 0.129974518,
0.119767074, 0.156117192, 0.247704064, 0.117449391, 0.136662939,
0.151347139, 0.202406527, 0.406609195), ASV3137 = c(0.247602441,
0, 0.05474177, 0.253953967, 0.032965222, 0, 0.043831144, 0, 0,
0, 0.031945966, 0, 0, 0, 0.088324461, 0, 0, 0.12025494, 0.020650846,
0.028940768, 0.58397242, 1.883176953, 0.909590896, 0.848393099,
0.475501718, 1.619525177, 0.665258455, 0.843382594, 0.577258692,
0.574026798, 0.523854069, 0.468437158, 0.319707032, 0.384118838,
0.55819723, 0.440966512, 0.368595651, 0.51173397, 0.38112246,
0.349221527, 0.518554529, 0.482424677, 0.403506665, 0.067320423,
0.075651381, 0.237478411, 0.232919255, 0.340954673, 0, 0.042754776,
0.166572597, 0.176932818, 0.338840465, 0.119080632, 0.181034024,
0.242754818, 0.248351566, 0.442528736), ASV852 = c(0.394071491,
0.344904941, 0.458698278, 1.835540697, 0.564529421, 0.323325635,
0.210087209, 0.087452042, 0.059625064, 0.063231979, 0.282949982,
0.09831427, 0.072389455, 0.048203164, 0.300780597, 0.105928803,
0.098320525, 0.192407905, 0.098091518, 0.062704997, 0.049250686,
0.464737236, 0.727672717, 0.072539187, 0.052431748, 0.209337423,
0.17238449, 0.246720878, 0.130890052, 0.56345262, 0.123479888,
0.162441918, 0.358943804, 0.117945203, 0.219895878, 0.191567419,
0.18982676, 0.477618372, 0.115425659, 0.149666369, 0.127838096,
0.179340029, 0.389095713, 0.029172183, 0.03782569, 0.017271157,
0.018485655, 0.035655391, 0, 0.027363056, 0.026156028, 0, 0.009347323,
0.024468623, 0.017748434, 0.056942488, 0.052153829, 0.104885057
), ASV132 = c(0.153443766, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0.281432491, 0.334787014, 0, 0.375311445,
0.329054421, 0.274248251, 0.349624882, 0.269378918, 0.244999329,
0.217525945, 0.269410664, 0.271995769, 0.20344993, 0.336303215,
0.261243821, 0.316266965, 0.276446738, 0.229831397, 0.328854237,
0.342985428, 0.23046868, 0.306671449, 0.09367119, 0.222157395,
0.33153105, 0.345423143, 0.266193434, 0.249587735, 1.811594203,
0.251398081, 0.312495698, 0.223767975, 0.254714556, 0.143549255,
0.246703228, 0.206791141, 0.290571333, 0.375), ASV1774 = c(0.191804708,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.433546753,
0.940487203, 0, 1.110164948, 1.289097812, 0.725378511, 0.852210649,
0.795548954, 0.822258021, 0.38671279, 0.883068288, 0.951985191,
0.310987749, 0.873432046, 0.945364332, 0.880125784, 0.779579801,
0.21905805, 0.6794869, 0.968673998, 0.889465061, 0.674318508,
0.18734238, 0.451046833, 0.545134949, 1.265112263, 1.73025732,
1.713687213, 0.724637681, 0.458331196, 0.839746149, 1.385973738,
1.161404903, 0.871082981, 1.150098504, 0.991998082, 1.189604003,
1.102011494), ASV755 = c(0, 0, 0, 0.10286743, 0.263721774, 0.791817882,
0.128470595, 0.66858497, 0.994335619, 0.976888254, 0.104965316,
0.177445268, 0.250346866, 0.408458387, 0.742402903, 1.213366289,
1.721612457, 0.372790315, 0.416458724, 0.223487041, 0, 0.061671292,
0, 0, 0, 0.04543758, 0.094690072, 0.103219959, 0, 0.070998051,
0, 0, 0.056675338, 0.140259161, 0.238690398, 0.09397647, 0.129008478,
0.237013628, 0.209072892, 0.128879373, 0, 0.071736011, 0.413113967,
0.029172183, 0.03782569, 0, 0, 0, 0, 0.029073247, 0, 0.015611719,
0.079452247, 0.030993589, 0.033722024, 0, 0.048428555, 0.057471264
), X = c(40L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), class = "data.frame", row.names = c(NA,
-58L))

com = df[,7:40]
cc = cor(com, method = "spearman")
corrplot(cc)

I am able to create a correlation heatmap showing the correlation of each individual ASV to another ASV but I would like show if individual ASVs are correlated to any environmental variables, such as temperature, salinity, oxygen etc.

In cor(), you can indicate both x and y arguments to compute the correlations between them.

com = df[,7:40]
vars = df[,3:6]

cc = cor(com, vars, method = "spearman")

And the style of Figure 3 is probably easier to get to using pheatmap:

annot <- data.frame(taxon = sample(LETTERS[1:3], ncol(com), replace = TRUE),
                    row.names = colnames(com))
pheatmap::pheatmap(cc,
                   color = colorRampPalette(c("blue4", "yellow2"))(50),
                   annotation_row = annot)

Thank you so much!! I am a little confused by the first part of your code

annot <- data.frame(taxon = sample(LETTERS[1:3], ncol(com), replace = TRUE),
row.names = colnames(com))

What is this doing? You are assigning a letter to each taxon? Is this randomized?

Yes, it's just to illustrate this capability of pheatmap that they seem to have used in the Figure 3: if you have a data frame whose rownames match the names in the matrix, you can add an annotation on the side with e.g. the taxon.

As I didn't want to write a whole data frame just for the example, I quickly generated some random example; of course you would have to use real data.

I'm working on a microbiome project and have successfully created a correlation heatmap for individual ASVs using the corrplot package. I'm now eager to take it a step further and generate a plot similar to Figure 3 in a referenced article, where ASVs are correlated with different environmental variables.
visit it

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.