-
Notifications
You must be signed in to change notification settings - Fork 0
/
Manuscript-figures.Rmd
1478 lines (1153 loc) · 59.7 KB
/
Manuscript-figures.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "FireSim2019_ManuscriptFigures"
author: "Dana Johnson"
date: "9/9/2021"
output: html_document
---
```{r setup, include=FALSE}
library(ggplot2)
library(dplyr)
library(tidyr)
library(phyloseq)
library(cowplot)
library(vegan)
library(tidyverse)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(out.width = '100%')
```
Defaults = theme_bw(), black = O, "organic"; grey40 - M, "mineral"; shapes = circle, triangle
# Metadata
```{r, include=FALSE}
df.meta <- read.csv('../../data/all-sample-metadata.csv')
df.meta <- subset(df.meta, core.id != '19UW-WB-11-02' &
Full.id != '19UW-WB-06-08-A-SI-duplicate' &
Full.id != '19UW-WB-07-02-O-SI-duplicate' &
Full.id != '19UW-WB-11-03-O-SI-duplicate' &
Full.id != '19UW-WB-19-07-A-SI-duplicate' &
Full.id != '19UW-WB-08-10-O-SI')
# Assign degree hours by horizon:
for (i in 1:nrow(df.meta)) {
if (df.meta$PRE.O.hor.thickness.cm[i] == 10) {
df.meta$hrzn.degree.hrs[i] = (df.meta$Low.degree.C.hours[i] + df.meta$Mid.degree.C.hours[i])/2
} else if (df.meta$horizon[i] == 'A') {
df.meta$hrzn.degree.hrs[i] = df.meta$Low.degree.C.hours[i]
} else {
df.meta$hrzn.degree.hrs[i] = df.meta$Mid.degree.C.hours[i]
}
}
# Create labels and palettes for plots
HorizonLabels = c('Organic','Mineral')
names(HorizonLabels) = c('O','A')
DNALabels = c('RNA','DNA')
names(DNALabels) = c('cDNA','gDNA')
ComparisonLabels = c('dry vs. unburned','wet vs. unburned')
names(ComparisonLabels) = c("DvC",'WvC')
# Edit names of Leading Species
VegLabels_Condensed = c("Picea spp.","Pinus banksiana","Populus \n tremuloides")
names(VegLabels_Condensed) <- c("Picea","Pinus_banksiana","Populus_tremuloides")
VegLabels_Full = c("Picea glauca","Picea mariana","Pinus banksiana","Pinus banksiana \n overstory","Populus \n tremuloides")
names(VegLabels_Full) <- c("Picea_glauca","Picea_mariana","Pinus_banksiana","Pinus_banksiana overstory piceglauc understory","Populus_tremula")
ThermoLabels = c('Organic-mineral \ninterface','Core base')
names(ThermoLabels) <- c('Mid','Low')
BurnLabels = c('Dry soil burn','Wet soil burn', 'Control')
names(BurnLabels) <- c('dry','wet', 'control')
# Edit names of Site
SiteLabels <- c("Site 01","Site 02","Site 03","Site 04","Site 05","Site 06",
"Site 07","Site 08","Site 09","Site 10","Site 11","Site 12",
"Site 13","Site 14","Site 15","Site 16","Site 17","Site 18",
"Site 19")
names(SiteLabels) <- c("1","2","3","4","5","6","7","8","9","10","11",
"12","13","14","15","16","17","18","19")
BurnSeverityLabels = c('Wet burn','Dry burn')
names(BurnSeverityLabels) <- c("Low_Sev",'High_Sev')
IncubLabels = c('24 hours post-burn','5 weeks post-burn', '6 months post-burn', '6 months post-burn: \nAutoclaved','6 months post-burn: \nNot autoclaved')
names(IncubLabels) = c('pb','SI', 'LI', 'LIwA','LIn')
CoefsLabel = c('Slow pool (M2)', 'Fast pool (M1)', 'Slow pool decay rate (k2)','Fast pool decay rate (k1)')
names(CoefsLabel) = c('M2','M1', 'k2','k1')
# Reorder burn treatment levels
df.meta$horizon =factor(df.meta$horizon, levels = c('O','A'))
df.meta$incub.trtmt = factor(df.meta$incub.trtmt, levels = c('pb','SI','LIwA','LIn'))
df.meta$burn.trtmt = factor(df.meta$burn.trtmt, levels = c('control','wet','dry'))
```
# Load phyloseq objects
```{r, message = FALSE}
# Starting phyloseq:
### Normalized + tree
ps.norm.full <- readRDS('../../data/sequence-data/LibCombined/phyloseq-objects/ps.norm.full')
ps.norm.full <- prune_taxa(taxa_sums(ps.norm.full)>0, ps.norm.full)
ps.norm.full <- prune_samples(sample_data(ps.norm.full)$Full.id != '19UW-WB-06-08-A-SI-duplicate' &
sample_data(ps.norm.full)$Full.id != '19UW-WB-07-02-O-SI-duplicate' &
sample_data(ps.norm.full)$Full.id != '19UW-WB-11-03-O-SI-duplicate'&
sample_data(ps.norm.full)$Full.id != '19UW-WB-19-07-A-SI-duplicate' &
sample_data(ps.norm.full)$Full.id != '19UW-WB-08-10-O-SI', ps.norm.full)
ps.raw.full <- readRDS('../../data/sequence-data/LibCombined/phyloseq-objects/ps.raw.full')
ps.raw.full <- prune_samples(sample_data(ps.raw.full)$Full.id != '19UW-WB-06-08-A-SI-duplicate' &
sample_data(ps.raw.full)$Full.id != '19UW-WB-07-02-O-SI-duplicate' &
sample_data(ps.raw.full)$Full.id != '19UW-WB-11-03-O-SI-duplicate'&
sample_data(ps.raw.full)$Full.id != '19UW-WB-19-07-A-SI-duplicate' &
sample_data(ps.raw.full)$Full.id != '19UW-WB-08-10-O-SI', ps.raw.full)
ps.raw.full <- prune_taxa(taxa_sums(ps.raw.full)>0, ps.raw.full)
# Reorder vegetation:
sample_data(ps.norm.full)$Veg.type = factor(sample_data(ps.norm.full)$Veg.type, levels = c('Picea','Populus_tremuloides','Pinus_banksiana'))
sample_data(ps.norm.full)$horizon = factor(sample_data(ps.norm.full)$horizon, levels = c('O','A'))
sample_data(ps.norm.full)$incub.trtmt = factor(sample_data(ps.norm.full)$incub.trtmt, levels = c('pb', 'SI','LIwA','LIn'))
#Pull out just the gDNA samples:
ps.norm.gDNA <- prune_samples(sample_data(ps.norm.full)$DNA.type == 'gDNA', ps.norm.full)
ps.raw.gDNA <- prune_samples(sample_data(ps.raw.full)$DNA.type == 'gDNA', ps.raw.full)
ps.norm.cDNA <- prune_samples(sample_data(ps.norm.full)$DNA.type == 'cDNA', ps.norm.full)
ps.raw.cDNA <- prune_samples(sample_data(ps.raw.full)$DNA.type == 'cDNA', ps.raw.full)
```
# Figure 2A-C (burn temperature, pH and C:N change, respiration coefficients):
```{r}
# Temperature, Fig. 2A ----
df.Temp <-read.csv('../../data/burn-thermocouple-temp-logs/Temp-all-burns-clean.csv')
df.Temp$Thermo_position <- factor(df.Temp$Thermo_position, levels = c('Mid','Low'))
pTemp = ggplot(df.Temp, aes(x = time_hr,
y = Temp)) +
geom_point(aes(color = burn.trtmt), size=1) +
theme_bw()+
facet_wrap(~Thermo_position,scales = 'free_y', ncol=1,
labeller = labeller(Thermo_position = ThermoLabels,
burn.trtmt = BurnLabels)) +
labs(x = "Time (h)",
y = expression(paste("Thermocouple temperature ( ",degree ~ C, ")")),
color = "Burn treatment") +
#scale_color_manual(values = c("black","grey70"),
# labels = c('O horizon/mineral \n interface','9 cm'),
# breaks = c('wet','dry')) +
scale_color_manual(values = c('orange','red'),
limits = c('wet','dry'),
labels = c('Moist soil burn','Dry soil burn')) +
theme(axis.title.x = element_text(size = 14),
axis.title.y = element_text(size = 14),
axis.text = element_text(size=14),
strip.text.y = element_text(size=14),
strip.text.x = element_text(size=14),
legend.text = element_text(size=12),
legend.title = element_text(size=12),
legend.position = 'right',
strip.background = element_rect(colour="black", fill="grey92")) +
geom_hline(yintercept=100)
pTemp
# pH and C:N change, Fig. 2B ----
pChange_pH <- ggplot(subset(df.meta, incub.trtmt == 'SI')) +
geom_boxplot(aes(x=horizon, y = pH, fill = burn.trtmt), varwidth = FALSE) +
theme_bw()+
labs(x= 'Soil horizon',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'Soil pH',
fill = 'Burn treatment') +
scale_fill_manual(values = c('grey50','orange','red'),
limits = c('control','wet','dry'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
scale_x_discrete(limits = c('O','A'),
labels = c('Organic','Mineral')) +
#scale_fill_manual(values = c("deepskyblue3","saddlebrown"),
# scale_fill_manual(values = c("slateblue4","palegreen3"),
# #scale_fill_manual(values = c("darkgreen","saddlebrown"),
# limits = c('O','A'),
# labels = c('Organic','Mineral')) +
# scale_x_discrete(limits = c('control','wet','dry'),
# labels = c('Unburned\ncontrol','Wet soil\nburn','Dry soil\nburn')) +
theme(axis.text.y = element_text(size = 14),
legend.title = element_text(size=14),
axis.text.x = element_text(size = 14),
axis.title.x = element_text(size = 14, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=14),
legend.text = element_text(size=14),
legend.position = '',
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical")
pChange_CN <- ggplot(subset(df.meta, incub.trtmt == 'SI' &site !=10)) +
geom_boxplot(aes(x=horizon, y = C.N.ratio, fill = burn.trtmt), varwidth = FALSE) +
theme_bw()+
labs(x= 'Soil horizon',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'Soil C:N',
fill = 'Burn treatment') +
scale_fill_manual(values = c('grey50','orange','red'),
limits = c('control','wet','dry'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
scale_x_discrete(limits = c('O','A'),
labels = c('Organic','Mineral')) +
#scale_fill_manual(values = c("deepskyblue3","saddlebrown"),
# scale_fill_manual(values = c("slateblue4","palegreen3"),
# #scale_fill_manual(values = c("darkgreen","saddlebrown"),
# limits = c('O','A'),
# labels = c('Organic','Mineral')) +
# scale_x_discrete(limits = c('control','wet','dry'),
# labels = c('Unburned\ncontrol','Wet soil\nburn','Dry soil\nburn')) +
theme(axis.text.y = element_text(size = 14),
legend.title = element_text(size=12),
axis.text.x = element_text(size = 14),
axis.title.x = element_text(size = 14, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=14),
legend.text = element_text(size=12),
legend.position = '',
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical")
cowplot::plot_grid(pChange_pH, pChange_CN, ncol=2)
# Stats ----
df.stats <- subset(df.meta, incub.trtmt == 'SI' )
test = aov(C.N.ratio ~ burn.trtmt*horizon, subset(df.stats))
summary(test)
TukeyHSD(test)
# Respiration coefficients, Fig. 2C ----
# Decay model coefficients at end of 5 week incubation (Days=34)
# after adjusting for total C
df.coefs <- read.csv('../../data/2-pool-decay-model-output-SI-adjusted-for-total-C.csv') %>%
subset(t==34)
# df.coefs <- read.csv('../../data/2-pool-decay-model-output-LIwA-adjusted-for-total-C.csv') %>%
# subset(t==180)
df.stack <- gather(df.coefs,
key = 'coefs',
value = value,M1,M2,k1,k2)
df.stack$coefs <- factor(df.stack$coefs, levels = c('M1', 'M2', 'k1', 'k2'))
pResp2 = ggplot(subset(df.stack, coefs %in% c('M1','M2')), aes(x=burn.trtmt)) +
geom_boxplot(aes(y=value, fill=burn.trtmt),varwidth = FALSE)+
#geom_boxplot(aes(y=log(M2), fill=burn.trtmt))+
theme_bw()+
labs(x= 'Burn treatment',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'Fractional pool size',
fill = 'Burn treatment',
color = 'Burn treatment') +
scale_fill_manual(values = c('grey50','orange','red'),
limits = c('control','wet burn','dry burn'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
scale_x_discrete(limits = c('control','wet burn','dry burn'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
#scale_x_discrete(limits = c('O','A'),
# labels = c('Organic','Mineral'))
facet_wrap(~coefs, ncol=1,scales = 'free_y',
labeller = labeller(coefs = CoefsLabel))+
theme(axis.text.y = element_text(size = 12),
legend.title = element_text(size=12),
axis.text.x = element_text(size = 12),
axis.title.x = element_text(size = 12, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=25, l=10)),
strip.text = element_text(size=12),
legend.text = element_text(size=12),
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical",
legend.position = '',
strip.background = element_rect(colour="black", fill="grey92"))
pResp1 = ggplot(subset(df.stack, coefs %in% c('k1','k2')), aes(x=burn.trtmt)) +
geom_boxplot(aes(y=value, fill=burn.trtmt),varwidth = FALSE)+
#geom_boxplot(aes(y=log(M2), fill=burn.trtmt))+
theme_bw()+
labs(x= 'Burn treatment',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'Decay rate',
fill = 'Burn treatment',
color = 'Burn treatment') +
scale_fill_manual(values = c('grey50','orange','red'),
limits = c('control','wet burn','dry burn'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
scale_x_discrete(limits = c('control','wet burn','dry burn'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
#scale_x_discrete(limits = c('O','A'),
# labels = c('Organic','Mineral'))
facet_wrap(~coefs, ncol=1,scales = 'free_y',
labeller = labeller(coefs = CoefsLabel))+
theme(axis.text.y = element_text(size = 12),
legend.title = element_text(size=12),
axis.text.x = element_text(size = 12),
axis.title.x = element_text(size = 12, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=12),
legend.text = element_text(size=14),
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical",
legend.position = '',
strip.background = element_rect(colour="black", fill="grey92"))
cowplot::plot_grid(pResp2, pResp1, ncol=2)
# Stats ----
df.stats <- subset(df.meta, incub.trtmt != 'pb' & horizon == 'O')
summary(subset(df.stats, incub.trtmt == 'LIwA' & texture != 'organic' &
horizon == 'O' & burn.trtmt == 'wet')$k1)
sd(subset(df.stats, incub.trtmt == 'LIwA' & burn.trtmt == 'wet')$k1)
test = aov(k2 ~ burn.trtmt, subset(df.stats, incub.trtmt == 'LIwA' & texture != 'organic'))
summary(test)
TukeyHSD(test)
test = wilcox.test(M1~burn.trtmt, data = subset(df.stats, incub.trtmt == 'SI' & burn.trtmt != 'control'))
test
test = aov(M1 ~ texture, data = subset(df.meta, incub.trtmt %in% c('LIwA','LIn') & horizon == 'O'))
test
p = ggplot(df.stats, aes(x=burn.trtmt, y =k1)) +
geom_boxplot() +
facet_grid(~incub.trtmt) +
theme_bw()
```
# Figure 2D: RNA and DNA concentration (ng/g soil)
```{r}
df <- read.csv('../../data/raw-data/pb-RNA-and-DNA-conc.csv')
colnames(df)[1] <- 'core.id.hor.incub'
df.sub <- df.meta %>%
subset(incub.trtmt == 'pb') %>%
subset(select = c(core.id.hor.incub, DNA.type, horizon, burn.trtmt))
df.DNA <- subset(df, DNA.type == 'gDNA') %>%
mutate(Conc.DNA = Concentration_ng.uL) %>%
subset(select = c('core.id.hor.incub', 'Conc.DNA'))
df.RNA <- subset(df, DNA.type == 'cDNA') %>%
mutate(Conc.RNA = Concentration_ng.uL) %>%
subset(select = c('core.id.hor.incub', 'Conc.RNA'))
df <- merge(df, df.sub)
NaLabels = c('RNA','DNA')
names(NaLabels) <- c('cDNA','gDNA')
p1 = ggplot(df) +
geom_boxplot(aes(x=horizon, y = nucleic.acid.conc.in.soil.ng.per.g/1000, fill = burn.trtmt),varwidth = FALSE) +
theme_bw()+
facet_wrap(~DNA.type, ncol=2, labeller = labeller(DNA.type = NaLabels))+
labs(x= 'Soil horizon',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'Concentration\n(ug/g soil)',
fill = 'Burn treatment') +
scale_fill_manual(values = c('grey50','orange','red'),
limits = c('control','wet','dry'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
scale_x_discrete(limits = c('O','A'),
labels = c('Organic','Mineral')) +
# scale_fill_manual(values = c("darkgreen","grey70"),
# limits = c('O','A'),
# labels = c('Organic','Mineral')) +
# scale_x_discrete(limits = c('control','wet','dry'),
# labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
theme(axis.text.y = element_text(size = 14),
legend.title = element_text(size=14),
axis.text.x = element_text(size = 13),
axis.title.x = element_text(size = 14, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=14),
legend.text = element_text(size=14),
legend.position = '',
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical")
p1
p_DNA = ggplot(subset(df, DNA.type == 'gDNA')) +
geom_boxplot(aes(x=horizon, y = nucleic.acid.conc.in.soil.ng.per.g/1000, fill = burn.trtmt),varwidth = FALSE) +
theme_bw()+
labs(x= 'Soil horizon',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'DNA concentration\n(ug/g soil)',
fill = 'Burn treatment') +
scale_fill_manual(values = c('grey50','orange','red'),
limits = c('control','wet','dry'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
scale_x_discrete(limits = c('O','A'),
labels = c('Organic','Mineral')) +
# scale_fill_manual(values = c("darkgreen","grey70"),
# limits = c('O','A'),
# labels = c('Organic','Mineral')) +
# scale_x_discrete(limits = c('control','wet','dry'),
# labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
theme(axis.text.y = element_text(size = 14),
legend.title = element_text(size=14),
axis.text.x = element_text(size = 13),
axis.title.x = element_text(size = 14, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=14),
legend.text = element_text(size=14),
legend.position = '',
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical")
p_RNA = ggplot(subset(df, DNA.type == 'cDNA')) +
geom_boxplot(aes(x=horizon, y = nucleic.acid.conc.in.soil.ng.per.g/1000, fill = burn.trtmt),varwidth = FALSE) +
theme_bw()+
labs(x= 'Soil horizon',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'RNA concentration\n(ug/g soil)',
fill = 'Burn treatment') +
scale_fill_manual(values = c('grey50','orange','red'),
limits = c('control','wet','dry'),
labels = c('Unburned control','Moist soil burn','Dry soil burn')) +
scale_x_discrete(limits = c('O','A'),
labels = c('Organic','Mineral')) +
# scale_fill_manual(values = c("darkgreen","grey70"),
# limits = c('O','A'),
# labels = c('Organic','Mineral')) +
# scale_x_discrete(limits = c('control','wet','dry'),
# labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
theme(axis.text.y = element_text(size = 14),
legend.title = element_text(size=14),
axis.text.x = element_text(size = 13),
axis.title.x = element_text(size = 14, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=14),
legend.text = element_text(size=14),
legend.position = '',
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical")
cowplot::plot_grid(p_DNA, p_RNA, ncol=2)
test <- aov(nucleic.acid.conc.in.soil.ng.per.g ~ burn.trtmt*horizon, data = subset(df, DNA.type == 'gDNA'))
summary(test)
TukeyHSD(test)
```
# Lab and field ordination, Figure 3 -----
See "Merged_paper_figures_Revision_Github.R" script
# Trait abundance in field data, Figure 4: ----
See "Merged_paper_figures_Revision_GitHub.R" script
# Rel abundance adjusted by copy num, Figure 5 -----
See "Merged_paper_figures_Revision_GitHub.R" script
# Total trait abun by BC dissimilarity, Figure 6 -----
See "Merged_paper_figures_Revision_GitHub.R" script
# Supplementary
```{r}
# Carbon and nitrogen loss, Figure S2 -----
pChange_C <- ggplot(subset(df.meta, incub.trtmt == 'SI')) +
geom_boxplot(aes(x=burn.trtmt, y = percent.total.C, fill = horizon), alpha = 0.7, varwidth = FALSE) +
theme_bw()+
labs(x= 'Burn treatment',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'Total C (%)',
fill = 'Soil horizon') +
scale_fill_manual(values = c('black','grey90'),
limits = c('O','A'),
labels = c('Organic','Mineral')) +
scale_x_discrete(limits = c('control','wet','dry'),
labels = c('Unburned\ncontrol','Wet soil\nburn','Dry soil\nburn')) +
theme(axis.text.y = element_text(size = 14),
legend.title = element_text(size=14),
axis.text.x = element_text(size = 14),
axis.title.x = element_text(size = 14, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=14),
legend.text = element_text(size=14),
legend.position = '',
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical")
pChange_N <- ggplot(subset(df.meta, incub.trtmt == 'SI')) +
geom_boxplot(aes(x=burn.trtmt, y = percent.total.N, fill = horizon), alpha = 0.7, varwidth = FALSE) +
theme_bw()+
labs(x= 'Burn treatment',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'Total N (%)',
fill = 'Soil horizon') +
scale_fill_manual(values = c('black','grey90'),
limits = c('O','A'),
labels = c('Organic','Mineral')) +
scale_x_discrete(limits = c('control','wet','dry'),
labels = c('Unburned\ncontrol','Wet soil\nburn','Dry soil\nburn')) +
theme(axis.text.y = element_text(size = 14),
legend.title = element_text(size=14),
axis.text.x = element_text(size = 14),
axis.title.x = element_text(size = 14, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=14),
legend.text = element_text(size=14),
legend.position = '',
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical")
cowplot::plot_grid(pChange_C, pChange_N, ncol=2)
test <- aov(percent.total.N ~ burn.trtmt, data = subset(df.meta, incub.trtmt == 'SI' & horizon == 'O'))
summary(test)
TukeyHSD(test)
# C remaining as fraction of total, Figure S3, S4 -----
# See incubations_microbial_respiration.R
# Full ordination, Fig. S6 ----
ps.full.dataset <-readRDS('../../../CombinedFireSim1519/ps.1519FireSim.merged')
tree <- ape::read.tree('../../../CombinedFireSim1519/tree/merged-exported-tree/tree.nwk')
tree <- phy_tree(tree)
tax <- tax_table(ps.full.dataset)
otu <- otu_table(ps.full.dataset)
sam <- sample_data(ps.full.dataset)
ps.full.dataset = phyloseq::phyloseq(otu,tax, sam,tree)
ps.full.dataset
# Setting some plot parameters
year.labs = c("One year post-fire","Five years post-fire")
names(year.labs) = c(1,5)
horizon.labs = c("Mineral","Organic")
# Playing with new datasets
ps = ps.full.dataset
# Add column with pairs info
sample_data(ps)$Pairs = paste(sample_data(ps)$Site_ID,sample_data(ps)$Org_or_Min,sep="_")
head(sample_data(ps)$Pairs)
# Normalize sample counts
ps.norm = transform_sample_counts(ps,function(x) x/sum(x))
sample_data(ps.norm)$Study = sample_data(ps.norm)$Years_Since_Fire
sample_data(ps.norm)$Study[is.na(sample_data(ps.norm)$Study)]="Lab"
ord.nmds = ordinate(ps.norm,method = "NMDS",ddistance="wunifrac",k=3, weighted=TRUE)
plot_ordination(ps.norm,ord.pcoa,color="burn.trtmt",shape="incub.trtmt")
plot_ordination(ps.norm,ord.nmds,color="pH",shape="Study")
# Neat, they all fall out on top of each other. That's nice.
colnames(sample_data(ps.norm))
ps.norm.gDNA <- prune_samples(sample_data(ps.norm.gDNA)$incub.trtmt %in% c('pb','SI','LIwA'), ps.norm.gDNA)
ps.norm.gDNA <- prune_taxa(taxa_sums(ps.norm.gDNA)>0,ps.norm.gDNA)
MyNMDS.full.gDNA <- ordinate(ps.norm.gDNA, method = 'NMDS', k=3, ddistance="wunifrac", weighted=TRUE)
# Ordination plot with horizons and deg.hrs
p1 = plot_ordination(ps.norm.gDNA, MyNMDS.full.gDNA, axes = c(1,2),
color = "burn.trtmt",
shape = 'incub.trtmt') +
facet_grid(~horizon, labeller = labeller(horizon = HorizonLabels,
DNA.type = DNALabels,
incub.trtmt = IncubLabels))+
#facet_grid(~horizon, labeller = labeller(horizon = HorizonLabels))+
geom_point(size=3, alpha=0.8) +
#geom_line(aes(group = core.id.hor)) +
labs(color = 'Burn treatment',
#color = expression("Degree ("*degree*C*") hours"),
shape = 'experiment') +
#scale_color_gradientn(colours = c('gold2','red','red4','black')) +
scale_color_manual(values = c('black','orange','red'),
labels = c('Unburned control', 'Wet soil burn','Wry soil burn'),
breaks = c('control','wet','dry'))+
scale_shape_manual(values = c('circle','square','triangle'),
labels = c('Fire survival', 'Fast growth','Post-fire envir. affinity'),
breaks = c('pb','SI','LIwA')) +
#scale_shape_discrete(labels = c('Picea' = 'Picea spp.', 'Populus_tremuloides' = 'Populus tremuloides','Pinus_banksiana' = 'Pinus banksiana')) +
#scale_shape_manual(values = c('circle','triangle'),
# labels = c('O horizon','Mineral'),
# breaks = c('O','A')) +
theme(legend.text = element_text(face = 'italic',size = 16),
axis.title = element_text(size=16),
axis.text = element_text(size=16),
legend.title = element_text(size=16)) +
theme_bw()
p1
# BC dissimilarity and pH change, Figure S7-----
df.distances <- read.csv('../../data/bray-curtis-dissimilarites.csv')
df.distances <- merge(df.distances, subset(df.meta, burn.trtmt != 'control'))
df.distances$incub.trtmt <- factor(df.distances$incub.trtmt, levels = c('pb','SI','LIwA','LIn'))
df.distances$horizon <- factor(df.distances$horizon, levels = c('O','A'))
# plot: Dry soil burns
p3=ggplot(subset(df.distances, incub.trtmt == 'LIwA' & burn.trtmt == 'dry'),
aes(x=change.pH, y = BC.distance.btw.burned.and.control, color = horizon, shape = horizon)) +
geom_point(size=3, alpha = 0.8) +
theme_bw() +
facet_wrap(~horizon,ncol=2,
labeller = labeller(horizon = HorizonLabels),
scales = 'fixed') +
labs(x = expression(Delta~'pH with burning'),
y = 'Bray-Curtis dissimilarity \ncompared to control',
color = 'Soil horizon',
shape = 'Soil horizon') +
scale_color_manual(values = c("darkgreen","grey70"),
limits = c('O','A'),
labels = c('Organic','Mineral')) +
scale_shape_manual(values = c('circle','triangle'),
limits = c('O','A'),
labels = c('Organic','Mineral')) +
theme(axis.title.x = element_text(size=14, margin = margin(t=10)),
axis.title.y = element_text(size=14, margin = margin(r=10)),
axis.text = element_text(size=12),
legend.title = element_text(size=14),
legend.text = element_text(size=14),
strip.text = element_text(size=14),
panel.spacing.x = unit(2, "lines"),
legend.position = 'right') +
stat_smooth(data = subset(df.distances, incub.trtmt == 'LIwA' & burn.trtmt == 'dry' & horizon == 'O'),
method=lm,se = FALSE,color='black') +
ylim(0,1)
# Respiration rate figures, S8, S9, S10-----
# See "incubations_microbial_respiration.R" script
# Traits as fraction of total reads in lab data, Figure S11-----
df <- read.csv('../../data/sequence-data/LibCombined/corncob-output/Manuscript/Trait-responder-OTUs.csv')
ps.responders <- prune_taxa(taxa_names(ps.norm.full) %in% df$OTU, ps.norm.full)
df.melt <- psmelt(ps.responders)
responders <- df.melt %>% group_by(Sample) %>% summarize(Abundance)
max(responders$Abundance)
mean(responders$Abundance)
dry <- subset(df.melt, burn.trtmt == 'dry') %>% subset(select = c(Sample, horizon, burn.trtmt, Abundance, incub.trtmt, Thermo.mid.max)) %>% group_by(Sample) %>% mutate(total.Abun = sum(Abundance))
summary(dry)
# Total gDNA reads in lab experiments: 39115
# Total reads in lab experiments: 43450
# Number responders = 117
# max abundance in lab data = 60%
# mean abundance, dry burns = 0.15% +/- 14%
df.frac.of.total <- df.melt %>% subset(select = c(Sample, horizon, burn.trtmt, Veg.type, Abundance, DNA.type, incub.trtmt, Thermo.mid.max, site)) %>% group_by(Sample) %>% mutate(total.Abun = sum(Abundance))
p_FractionTotal <- ggplot(subset(df.frac.of.total, DNA.type == 'cDNA'), aes(x=site, y=total.Abun, fill=burn.trtmt)) +
geom_bar(stat='identity', position='dodge') +
facet_wrap(~horizon+incub.trtmt, labeller = labeller(horizon = HorizonLabels)) +
theme_bw()+
labs(x= 'Sampling site ID',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'Fraction of total reads',
fill = 'Burn treatment') +
scale_fill_manual(values = c('grey50','orange','red'),
limits = c('control','wet','dry'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
theme(axis.text.y = element_text(size = 14),
legend.title = element_text(size=14),
axis.text.x = element_text(size = 14),
axis.title.x = element_text(size = 14, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=14),
legend.text = element_text(size=14),
legend.position = '',
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical")
df.frac.of.total$burn.trtmt <- factor(df.frac.of.total$burn.trtmt, levels = c('control','wet','dry'))
p_FractionTotal <- ggplot(subset(df.frac.of.total,incub.trtmt!='LIn'), aes(x=horizon, y=total.Abun, fill=burn.trtmt)) +
geom_boxplot()+
facet_wrap(~incub.trtmt+DNA.type, labeller = labeller(incub.trtmt = IncubLabels, DNA.type = DNALabels)) +
theme_bw()+
labs(x= 'Soil horizon',
# y = 'Decay rate constant for fast C pool \nlog(k1)',
y = 'Fraction of total reads',
fill = 'Burn treatment') +
scale_fill_manual(values = c('grey50','orange','red'),
limits = c('control','wet','dry'),
labels = c('Unburned\ncontrol','Moist soil\nburn','Dry soil\nburn')) +
scale_x_discrete(limits = c('O','A'),
labels = c('Organic','Mineral')) +
theme(axis.text.y = element_text(size = 14),
legend.title = element_text(size=14),
axis.text.x = element_text(size = 14),
axis.title.x = element_text(size = 14, margin = margin(t=10, b=10)),
axis.title.y = element_text(size = 14, margin = margin(r=10, l=10)),
strip.text = element_text(size=14),
legend.text = element_text(size=14),
legend.position = '',
# legend.background = element_rect(fill = "darkgray"),
legend.box = "vertical")
```
# PERMANOVAs, Supplementary:
```{r}
ps.E1 <- prune_samples(sample_data(ps.norm.full)$incub.trtmt == 'pb' &
sample_data(ps.norm.full)$DNA.type == 'cDNA', ps.norm.full)
ps.E1 <- prune_taxa(taxa_sums(ps.E1)>0, ps.E1)
ps.E1
ps.E1.DNA <- prune_samples(sample_data(ps.norm.full)$incub.trtmt == 'pb' &
sample_data(ps.norm.full)$DNA.type == 'gDNA', ps.norm.full)
ps.E1.DNA <- prune_taxa(taxa_sums(ps.E1.DNA)>0, ps.E1.DNA)
ps.E1.DNA
ps.E2 <- prune_samples(sample_data(ps.norm.full)$incub.trtmt == 'SI' &
sample_data(ps.norm.full)$DNA.type == 'gDNA', ps.norm.full)
ps.E2 <- prune_taxa(taxa_sums(ps.E2)>0, ps.E2)
ps.E2
ps.E3 <- prune_samples(sample_data(ps.norm.full)$incub.trtmt == 'LIwA' &
sample_data(ps.norm.full)$DNA.type == 'gDNA', ps.norm.full)
ps.E3 <- prune_taxa(taxa_sums(ps.E3)>0, ps.E3)
ps.E3
MyWunifrac_E1 <- distance(ps.E1, method = 'wunifrac')
MyWunifrac_E1.DNA <- distance(ps.E1.DNA, method = 'wunifrac')
MyWunifrac_E2 <- distance(ps.E2, method = 'wunifrac')
MyWunifrac_E3 <- distance(ps.E3, method = 'wunifrac')
MyWunifrac_All <- distance(ps.norm.gDNA, method = 'wunifrac')
SamDat_E1 = data.frame(sample_data(ps.E1))
SamDat_E1.DNA = data.frame(sample_data(ps.E1.DNA))
SamDat_E2 = data.frame(sample_data(ps.E2))
SamDat_E3 = data.frame(sample_data(ps.E3))
SamDat_All = data.frame(sample_data(ps.norm.gDNA))
test_E1 <- adonis(MyWunifrac_E1 ~ Veg.type+PRE.hor.thickness.cm+pH+percent.total.C+
percent.total.N+texture+burn.trtmt+horizon, data = SamDat_E1)
test_E1.DNA <- adonis(MyWunifrac_E1.DNA ~ Veg.type+PRE.hor.thickness.cm+pH+percent.total.C+
percent.total.N+texture+burn.trtmt+horizon, data = SamDat_E1.DNA)
test_E2 <- adonis(MyWunifrac_E2 ~ Veg.type+PRE.hor.thickness.cm+pH+percent.total.C+
percent.total.N+texture+burn.trtmt+horizon, data = SamDat_E2)
test_E3 <- adonis(MyWunifrac_E3 ~ Veg.type+PRE.hor.thickness.cm+pH+percent.total.C+
percent.total.N+texture+burn.trtmt+horizon, data = SamDat_E3)
test_All <- adonis(MyWunifrac_All ~ incub.trtmt+burn.trtmt+pH+horizon+Veg.type, data = SamDat_All)
test_E1
test_E1.DNA
test_E2
test_E3
test_All
test_E1_sub <- adonis(MyWunifrac_E1.DNA ~ percent.total.N, data = SamDat_E1.DNA)
test_E1_sub
# Fire survival
adonis(MyWunifrac_E1 ~ Veg.type, data = SamDat_E1)
adonis(MyWunifrac_E1 ~ PRE.hor.thickness.cm, data = SamDat_E1)
adonis(MyWunifrac_E1 ~ pH, data = SamDat_E1)
adonis(MyWunifrac_E1 ~ percent.total.C, data = SamDat_E1)
adonis(MyWunifrac_E1 ~ percent.total.N, data = SamDat_E1)
adonis(MyWunifrac_E1 ~ texture, data = SamDat_E1)
adonis(MyWunifrac_E1 ~ burn.trtmt, data = SamDat_E1)
adonis(MyWunifrac_E1 ~ horizon, data = SamDat_E1)
adonis(MyWunifrac_E1.DNA ~ Veg.type, data = SamDat_E1.DNA)
adonis(MyWunifrac_E1.DNA ~ PRE.hor.thickness.cm, data = SamDat_E1.DNA)
adonis(MyWunifrac_E1.DNA ~ pH, data = SamDat_E1.DNA)
adonis(MyWunifrac_E1.DNA ~ percent.total.C, data = SamDat_E1.DNA)
adonis(MyWunifrac_E1.DNA ~ percent.total.N, data = SamDat_E1.DNA)
adonis(MyWunifrac_E1.DNA ~ texture, data = SamDat_E1.DNA)
adonis(MyWunifrac_E1.DNA ~ burn.trtmt, data = SamDat_E1.DNA)
adonis(MyWunifrac_E1.DNA ~ horizon, data = SamDat_E1.DNA)
# Fast growth
adonis(MyWunifrac_E2 ~ Veg.type, data = SamDat_E2)
adonis(MyWunifrac_E2 ~ PRE.hor.thickness.cm, data = SamDat_E2)
adonis(MyWunifrac_E2 ~ pH, data = SamDat_E2)
adonis(MyWunifrac_E2 ~ percent.total.C, data = SamDat_E2)
adonis(MyWunifrac_E2 ~ percent.total.N, data = SamDat_E2)
adonis(MyWunifrac_E2 ~ texture, data = SamDat_E2)
adonis(MyWunifrac_E2 ~ burn.trtmt, data = SamDat_E2)
adonis(MyWunifrac_E2 ~ horizon, data = SamDat_E2)
# Test of autoclaving
ps.E3.autoclave <- prune_samples(sample_data(ps.norm.full)$incub.trtmt %in% c('LIwA','LIn'), ps.norm.full)
ps.E3.autoclave <- prune_taxa(taxa_sums(ps.E3.autoclave)>0, ps.E3.autoclave)
ps.E3.autoclave
SamDat <- data.frame(sample_data(ps.E3.autoclave))
head(SamDat,5)
MyWunifrac_E3.autoclave <- distance(ps.E3.autoclave, method = 'wunifrac')
SamDat_E3.autoclaving = data.frame(sample_data(ps.E3.autoclave))
adonis(MyWunifrac_E3.autoclave ~ Veg.type+PRE.hor.thickness.cm+pH+percent.total.C+
percent.total.N+texture+burn.trtmt+horizon + incub.trtmt, data = SamDat_E3.autoclaving)
adonis(MyWunifrac_E3.autoclave ~ Veg.type, data = SamDat_E3.autoclaving)
adonis(MyWunifrac_E3.autoclave ~ PRE.hor.thickness.cm, data = SamDat_E3.autoclaving)
adonis(MyWunifrac_E3.autoclave ~ pH, data = SamDat_E3.autoclaving)
adonis(MyWunifrac_E3.autoclave ~ percent.total.C, data = SamDat_E3.autoclaving)
adonis(MyWunifrac_E3.autoclave ~ percent.total.N, data = SamDat_E3.autoclaving)
adonis(MyWunifrac_E3.autoclave ~ texture, data = SamDat_E3.autoclaving)
adonis(MyWunifrac_E3.autoclave ~ burn.trtmt, data = SamDat_E3.autoclaving)
adonis(MyWunifrac_E3.autoclave ~ horizon, data = SamDat_E3.autoclaving)
adonis(MyWunifrac_E3.autoclave ~ incub.trtmt, data = SamDat_E3.autoclaving)
# All
adonis(MyWunifrac_All ~ Veg.type, data = SamDat_All)
adonis(MyWunifrac_All ~ pH, data = SamDat_All)
adonis(MyWunifrac_All ~ incub.trtmt, data = SamDat_All)
adonis(MyWunifrac_All ~ burn.trtmt, data = SamDat_All)
adonis(MyWunifrac_All ~ horizon, data = SamDat_All)
```
Bray-Curtis dissimilarity?
```{r, message = FALSE}
# This is a possibly convoluted piece of code to first create a Bray-Curtis
# dissimilarity matrix and then pull out the dissimilarities between dry/wet
# burns and corresponding control cores.
# First: Calculate Bray-curtis dissimilarity matrix ----
ps.cDNA.raw <- prune_samples(sample_data(ps.raw.full)$DNA.type == 'cDNA', ps.raw.full)
ps.cDNA.raw <- prune_taxa(taxa_sums(ps.cDNA.raw) > 0, ps.cDNA.raw)
dist.bray.full <- as.matrix(distance(ps.raw.full, method = 'bray', type = 'samples'))
# Look at some figures
hist(dist.bray.full)
heatmap(dist.bray.full)
# Convert distance matrix into dataframe
df <- data.frame(dist.bray.full)
# Bring in meta data and subset for specific analysis
df.meta.sub <- subset(df.meta, select = c(Full.id, burn.trtmt,site, DNA.type,
incub.trtmt,core, horizon,
pH, change.pH))
# Create a dataframe with the colnames and Full.ID
x <- data.frame(str_split(colnames(df)[1:460], 'X', simplify = TRUE)[,2])
# Rename columes:
colnames(x)[1] <- 'ID.bray'
# Clean up x.
x <- x %>%
mutate(Full.id = ID.bray)
x$Full.id <- str_replace_all(x$Full.id, "\\.", "-")
x$X <- 'X'
x <- x %>%
unite(Bray.ID, c('X',"ID.bray"), sep = '', remove = TRUE)
# Next, pull out the control cores from the meta data and assign them to "Control.id"
df.meta.control <- df.meta %>%
subset(burn.trtmt == 'control') %>%
mutate(Control.id = Full.id) %>%
subset(select = c(Control.id, site, horizon, incub.trtmt, DNA.type))
# Combine list of control cores with full df.meta
df.meta.list <- merge(subset(df.meta.sub, select = c(Full.id, site, horizon,
DNA.type,burn.trtmt, incub.trtmt,
pH, change.pH)),
df.meta.control, by = c('site', 'horizon', 'incub.trtmt', 'DNA.type'))
# ANd then combine the Full.id list with the control core meta data I just created.
# df.list now contains Full.id with the corresponding control sample for each
# dry/wet burn and a colume ("Bray.ID") that has the sample ID formatted to
# match the distance matrix names.
df.list <- x %>%
merge(df.meta.list, by = 'Full.id') %>%
subset(burn.trtmt != 'control')
df.list$burn.trtmt <- as.character(df.list$burn.trtmt)
df.list$horizon <- as.character(df.list$horizon)
df.list$incub.trtmt <- as.character(df.list$incub.trtmt)
# Create and empty data frame to store distances
df.distances <- data.frame("Full.id" = df.list$Full.id,
'control.core' = 'core',
#'burn.trtmt' = 'burn', 'horizon' = 'H',
#'DNA.type' = 'DNA.type',
'BC.distance.btw.burned.and.control' = 'distance'
#'incub.trtmt' = 'incub', 'pH' = 0
) %>%
unique()
# Now run a convoluted loop:
for (i in 1:nrow(df.list)) { # For each sample (row in df.list)
for (j in 1:nrow(df)) { # For each row in the dissimilarity matrix
for (k in 1:ncol(df)){ # And for each colume in the dissimilarity matrix
if(colnames(df)[k] == df.list$Bray.ID[i] & # If the distance matrix colume ID matches the sample ID in the list
rownames(df)[j] == df.list$Control.id[i]) { # And the rowname ID matches the corresponding control core, then...
df.distances$BC.distance.btw.burned.and.control[i] = df[j,k] # Pull out the distance and store it in new dataframe
#df.distances$burn.trtmt[i] = df.list$burn.trtmt[i]
df.distances$control.core[i] = df.list$Control.id[i]
#df.distances$horizon[i] = df.list$horizon[i]
#df.distances$incub.trtmt[i] = df.list$incub.trtmt[i]
#df.distances$DNA.type[i] = df.list$DNA.type[i]
#df.distances$pH[i] = df.list$pH[i]
#df.distances$change.pH[i] = df.list$change.pH[i]
}
}
}
}
df.distances$BC.distance.btw.burned.and.control <- as.numeric(df.distances$BC.distance.btw.burned.and.control)
# Save backup dataframe.
df.final <- df.distances
# -----
df.distances <- read.csv('../data/bray-curtis-dissimilarites.csv')
df.distances <- merge(df.distances, subset(df.meta, burn.trtmt != 'control'))
dim(df.distances)
# Plots ----
p=ggplot(subset(df.distances, DNA.type == 'cDNA')) +
geom_boxplot(aes(x=burn.trtmt, y = BC.distance.btw.burned.and.control, fill = horizon),
alpha = 0.7) +
theme_bw() +
facet_wrap(~incub.trtmt, ncol=4,
labeller = labeller(incub.trtmt = IncubLabels)) +
labs(x='Burn treatment',
y = 'Bray-Curtis dissimilarity \ncompared to control',
fill = 'Soil horizon') +
scale_fill_manual(values = c('black','grey40'),
limits = c('O','A'),
labels = c('Organic','Mineral')) +
scale_x_discrete(limits = c('wet','dry'),
labels = c('Moist soil \nburn','Dry soil \nburn')) +
theme(axis.title = element_text(size=18),
axis.text = element_text(size=18),
legend.title = element_text(size=18),
legend.text = element_text(size=18),
strip.text = element_text(size=18)) +
ylim(0,1)
test <- aov(BC.distance.btw.burned.and.control~burn.trtmt*horizon, data = subset(df.distances, DNA.type == 'cDNA'))
summary(test)
TukeyHSD(test)
```
Richness estimates?
If the community composition data of a single sample includes few singletons, we assume that sequencing captured most of the taxa present in the sample. If the data includes many singletons, we assume that sequencing missed many rare taxa. We can use breakaway to estiamte how many taxa were missed and use this to estimate richness.