-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverarching_script2023.R
2218 lines (1786 loc) · 84.1 KB
/
overarching_script2023.R
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
# goal: generate a single script that encompasses all the analyses for an upcoming manuscript.
# note: these analyses were performed years ago and this script is a compilation of multiple separate files. The script is provided as an example and not intended to be stand-alone reproducible code. The original scripts were subject editing including removing output, removing analyses that did not pan out, editing documentation, and obscuring file systems. There is no guarantee that all analyses from the manuscript are included in the script and there is no guarantee that all analyses included in the script are in the manuscript.
#AverageBMT.csv
#This dataset has had outliers removed.
#There are 3 lines of data for each plant - one for the Base, Middle, and Apex ("tip") - BMT. All data should be the same for each plant except for venation data.
#The "areole area" value is an average of all areole areas for that part of the leav (B/M/T).
#analysing areole area will likely require using a different dataset that includes each areole's area and slightly more complicated models (see APPS 2020 paper)
rm(list=ls())
gc()
setwd("~")
dat<-read.csv(file="AveragedBMT.csv")
dat1<-dat[,-c(1, 12,14,15,20,21,22,23,24,25,26,27,29, 37,38,46,47,48,49)]
names(dat1)
plot(dat1$Lf4_wetMg, dat1$Lf4_dryMg) #this plot looks really good. There is a nice (close to) 1:1 ratio of wet to dry.
Lf4<-lm(Lf4_dryMg~Lf4_wetMg, data=dat1)
# Call:
# lm(formula = Lf4_dryMg ~ Lf4_wetMg, data = dat1)
#
# Residuals:
# Min 1Q Median 3Q Max
# -45.002 -12.322 -1.305 11.996 45.184
#
# Coefficients:
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 25.810377 1.906392 13.54 <2e-16 ***
# Lf4_wetMg 0.059662 0.001056 56.50 <2e-16 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Residual standard error: 19.63 on 303 degrees of freedom
# (17 observations deleted due to missingness)
# Multiple R-squared: 0.9133, Adjusted R-squared: 0.913
# F-statistic: 3192 on 1 and 303 DF, p-value: < 2.2e-16
#R-squared = 0.913. That's pretty freaking good.
hist(Lf4$residuals) # looks super normal and centered around zero means this is a good fit.
library(ggplot2)
#https://www.dataquest.io/blog/statistical-learning-for-predictive-modeling-r/
#seems to be a very thorough explanation, unfortunatey all in very obtuse ggplot
pdf(file="Supplemental1_Lf4wet_vs_dry_mass.pdf")
ggplot(data=dat1, aes(x=Lf4_wetMg, y=Lf4_dryMg))+
geom_point() +
stat_smooth(method=lm, col="dodgerblue3")+
theme(panel.background = element_rect(fill="white"),
axis.line.x=element_line(),
axis.line.y=element_line())+
geom_text(x=1000, y=325, label="Rsquared=0.9133", size=5)+
ggtitle("Linear model fitted to data")
dev.off()
Lf4_wetMg<-dat1$Lf3_wetMg
Lf3_dryMg_pred<-predict(Lf4, data.frame(Lf4_wetMg))
plot(dat1$Lf3_wetMg, Lf3_dryMg_pred)
min(dat1$Lf4_wetMg, na.rm=TRUE) 88.9
max(dat1$Lf4_wetMg, na.rm=TRUE) 5933.1
min(dat1$Lf3_wetMg, na.rm=TRUE) 352.8
max(dat1$Lf3_wetMg, na.rm=TRUE) 5710.8
min(dat1$Lf4_dryMg, na.rm=TRUE) 12.1
max(dat1$Lf4_dryMg, na.rm=TRUE) 365.6
min(Lf3_dryMg_pred, na.rm=TRUE) 46.85898
max(Lf3_dryMg_pred, na.rm=TRUE) 366.6256
dat1$Lf3_dryMg_pred<-dat1$Lf3_dryMg_pred
#table2.R
#28 May 2020
#Test for the effect of species or parent/hybrid on venation and stomatal traits
#dat: 3 rows per plant: different data for B/M/T, all other data the same. Use for veination except areole area
#dat1: keeps only one of the 3 lines from dat ("Tip"). Used for non-veination analyses
#dat2: 56,000+ lines with many many observations of areole area from each B/M/T location on each plant. Used for areole area analyses.
rm(list=ls())
gc()
library(lme4)
library(emmeans)
install.packages("lsr") #for effect sizes
#Calculate effect size using etaSquared: SStreatment/SStotal
#########################################################
#### load datasets and get rid of NAs as necessary: ####
#########################################################
dat<-read.csv(file="avgBMT2020.csv") #venation except areole area
nrow(dat) #319
sum(is.na(dat$species)) #2
dat<-dat[-c(which(is.na(dat$species))),]
sum(is.na(dat$species))
nrow(dat) #317
319-317 #2
dat1<-dat[which(dat$loc=="T"),] #keep just one copy of each stomatal measurement
nrow(dat1) #107 Good! #LMA and stomata
dat2<-read.csv(file="all_veination_recalib.csv") #areole area
nrow(dat2) #56401
sum(is.na(dat2$species)) #191
dat2<-dat2[-c(which(is.na(dat2$species))),]
nrow(dat2) #56210
56401-56210 #191
############################################
######### Stomatal Traits ##################
############################################
hist(dat1$adaxial_density) #very normal
hist(dat1$abaxial_density) #also quite normal
hist(dat1$ab_ad_density) # a bit left-skewed a fair amount, may want to transform
hist(dat1$abaxial_density-dat$adaxial_density) #pretty normal
####Contrasts #########
str(dat1$species)
levels(dat1$species)
#[1] "carinata" "juncea" "napus" "nigra" "oleracea" "rapa"
#levels 1, 2, 3 (carinata, juncea, napus) are allotetraploid hybrids
#levels 4, 5, 6 (nigra, oleracea, rapa) are diploid parents
#set up contrasts
c1<-c(0,0,0,1,1,1)
mat<-cbind(c1)
contrasts(dat1$species)<-mat
#Run models:
model1<-aov(adaxial_density~species, data=dat1)
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 2.550e-08 5.100e-09 4.355 0.00126 **
#Residuals 100 1.171e-07 1.171e-09
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#1 observation deleted due to missingness
#summary(model1, split=list(species=list("Hybrids vs. Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 2.550e-08 5.100e-09 4.355 0.00126 **
# species: Hybrids vs. Parents 1 2.920e-09 2.925e-09 2.498 0.11718
#Residuals 100 1.171e-07 1.171e-09
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#1 observation deleted due to missingness
#EtaSquared.species<-2.550e-8/(2.550e-08+2.92e-09+1.171e-07)
#[1] 0.1751975
#etaSquared(model1) #0.1788194 #from lsr package. Darn close
#EtaSq.cont<-2.920e-09/(2.550e-08+2.92e-09+1.171e-07)
#[1] 0.02006597
model2<-aov(abaxial_density ~ species, data=dat1)
summary(model2)
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 2.586e-08 5.173e-09 2.82 0.02 *
#Residuals 100 1.835e-07 1.835e-09
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#1 observation deleted due to missingness
summary(model2, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 2.586e-08 5.173e-09 2.820 0.0200 *
# species: Hybrids vs Parents 1 5.710e-09 5.709e-09 3.112 0.0808 .
#Residuals 100 1.835e-07 1.835e-09
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#1 observation deleted due to missingness
model3<-aov(ab_ad_density ~ species, data=dat1)
summary(model3)
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 2.615 0.5231 2.735 0.0233 *
#Residuals 100 19.123 0.1912
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#1 observation deleted due to missingness
summary(model3, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 2.615 0.5231 2.735 0.0233 *
# species: Hybrids vs Parents 1 0.133 0.1331 0.696 0.4061
#Residuals 100 19.123 0.1912
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#1 observation deleted due to missingness
model4<-aov(abaxial_density-adaxial_density~ species, data=dat1)
summary(model4)
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 3.770e-09 7.537e-10 0.795 0.556
#Residuals 100 9.481e-08 9.481e-10
#1 observation deleted due to missingness
summary(model4, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 3.770e-09 7.537e-10 0.795 0.556
# species: Hybrids vs Parents 1 4.600e-10 4.612e-10 0.486 0.487
#Residuals 100 9.481e-08 9.481e-10
#1 observation deleted due to missingness
model5<-aov(LMA ~ species, data=dat1)
summary(model5)
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 3.125 0.6249 1.887 0.104
#Residuals 94 31.124 0.3311
#7 observations deleted due to missingness
summary(model5, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 3.125 0.6249 1.887 0.104
# species: Hybrids vs Parents 1 0.684 0.6839 2.066 0.154
#Residuals 94 31.124 0.3311
#7 observations deleted due to missingness
datB<-dat[which(dat$loc=="B"),]
sum(is.na(datB$species)) #0
datM<-dat[which(dat$loc=="M"),]
sum(is.na(datM$species)) #0
datT<-dat[which(dat$loc=="T"),]
sum(is.na(datT$species)) #0
####################BASE
hist(datB$branch_points) #right skewed a bit.
hist(datB$end_points) #better
hist(datB$areole_num) #also right skewed a bit
hist(datB$skel_length_new_mm) #not bad.
hist(datB$vein_dens_mm2) #also right skewed
#None of these are wonderfully normally distributed. Consider sqrt transformations.
################### MID
hist(datM$branch_points) #good
hist(datM$end_points) #good
hist(datM$areole_num) #good
hist(datM$skel_length_new_mm) #nice
hist(datM$vein_dens_mm2) #right skewed a bit
################### Tip
hist(datT$branch_points) #good
hist(datT$end_points) #good
hist(datT$areole_num) #good
hist(datT$skel_length_new_mm) #nice
hist(datT$vein_dens_mm2) #right skewed a bit
#################################################
################### BASE MODELS #################
#################################################
c1<-c(0,0,0,1,1,1)
mat<-cbind(c1)
contrasts(datB$species)<-mat
modB_vd<-aov(vein_dens_mm2~species, data=datB)
summary(modB_vd)
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 149.7 29.94 1.508 0.194
#Residuals 98 1945.9 19.86
#2 observations deleted due to missingness
summary(modB_vd, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 149.7 29.94 1.508 0.1943
# species: Hybrids vs Parents 1 59.1 59.10 2.976 0.0877 .
#Residuals 98 1945.9 19.86
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#2 observations deleted due to missingness
ModB_sl<-aov(skel_length_new_mm ~ species, data=datB)
summary(ModB_sl)
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 39460 7892 1.434 0.219
#Residuals 100 550233 5502
summary(ModB_sl, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 39460 7892 1.434 0.219
# species: Hybrids vs Parents 1 333 333 0.061 0.806
#Residuals 100 550233 5502
ModB_an<-aov(areole_num ~ species, data=datB)
summary(ModB_an)
# Df Sum Sq Mean Sq F value Pr(>F)
#species 5 177823 35565 2.962 0.0156 *
#Residuals 99 1188668 12007
#---
#Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#1 observation deleted due to missingness
summary(ModB_an, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 177823 35565 2.962 0.0156 *
# species: Hybrids vs Parents 1 3142 3142 0.262 0.6101
# Residuals 99 1188668 12007
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 1 observation deleted due to missingness
ModB_bp<-aov(branch_points ~ species, data=datB)
summary(ModB_bp)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 1595435 319087 4.054 0.00216 **
# Residuals 100 7870891 78709
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(ModB_bp, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 1595435 319087 4.054 0.00216 **
# species: Hybrids vs Parents 1 52645 52645 0.669 0.41540
# Residuals 100 7870891 78709
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
ModB_ep<-aov(end_points ~ species, data=datB)
summary(ModB_ep)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 108856 21771 3.178 0.0105 *
# Residuals 100 684954 6850
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
summary(ModB_ep, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 108856 21771 3.178 0.0105 *
# species: Hybrids vs Parents 1 2948 2948 0.430 0.5133
# Residuals 100 684954 6850
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#################################################
################### Middle MODELS #################
#################################################
c1<-c(0,0,0,1,1,1)
mat<-cbind(c1)
contrasts(datM$species)<-mat
ModM_vd<-aov(vein_dens_mm2~species, data=datM)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 219.7 43.95 3.923 0.00281 **
# Residuals 95 1064.3 11.20
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 3 observations deleted due to missingness
summary(ModM_vd, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 219.7 43.95 3.923 0.00281 **
# species: Hybrids vs Parents 1 20.5 20.46 1.826 0.17979
# Residuals 95 1064.3 11.20
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 3 observations deleted due to missingness
ModM_sl<-aov(skel_length_new_mm ~ species, data=datM)
# summary(ModM_sl)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 29237 5847 1.582 0.172
# Residuals 98 362124 3695
summary(ModM_sl, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 29237 5847 1.582 0.172
# species: Hybrids vs Parents 1 1468 1468 0.397 0.530
# Residuals 98 362124 3695
ModM_an<-aov(areole_num ~ species, data=datM)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 109932 21986 3.239 0.00957 **
# Residuals 96 651700 6789
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 2 observations deleted due to missingness
summary(ModM_an, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 109932 21986 3.239 0.00957 **
# species: Hybrids vs Parents 1 179 179 0.026 0.87134
# Residuals 96 651700 6789
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 2 observations deleted due to missingness
ModM_bp<-aov(branch_points ~ species, data=datM)
summary(ModM_bp)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 897677 179535 3.753 0.0038 **
# Residuals 96 4592514 47839
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 2 observations deleted due to missingness
summary(ModM_bp, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 897677 179535 3.753 0.0038 **
# species: Hybrids vs Parents 1 2451 2451 0.051 0.8214
# Residuals 96 4592514 47839
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 2 observations deleted due to missingness
ModM_ep<-aov(end_points ~ species, data=datM)
# summary(ModM_ep)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 132591 26518 4.556 0.000895 ***
# Residuals 97 564558 5820
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 1 observation deleted due to missingness
summary(ModM_ep, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 132591 26518 4.556 0.000895 ***
# species: Hybrids vs Parents 1 3 3 0.001 0.981734
# Residuals 97 564558 5820
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 1 observation deleted due to missingness
#######################################################
################### Tip (Apex) MODELS #################
#######################################################
c1<-c(0,0,0,1,1,1)
mat<-cbind(c1)
contrasts(datT$species)<-mat
ModT_vd<-aov(vein_dens_mm2~species, data=datT)
summary(ModT_vd)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 61.6 12.314 1.964 0.0906 .
# Residuals 99 620.6 6.269
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 2 observations deleted due to missingness
summary(ModT_vd, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 61.6 12.314 1.964 0.0906 .
# species: Hybrids vs Parents 1 1.7 1.651 0.263 0.6090
# Residuals 99 620.6 6.269
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 2 observations deleted due to missingness
ModT_sl<-aov(skel_length_new_mm ~ species, data=datT)
summary(ModT_sl)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 28101 5620 2.36 0.0454 *
# Residuals 100 238161 2382
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 1 observation deleted due to missingness
summary(ModT_sl, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 28101 5620 2.360 0.0454 *
# species: Hybrids vs Parents 1 3391 3391 1.424 0.2356
# Residuals 100 238161 2382
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 1 observation deleted due to missingness
ModT_an<-aov(areole_num ~ species, data=datT)
summary(ModT_an)
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 75343 15069 3.891 0.0029 **
# Residuals 100 387284 3873
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 1 observation deleted due to missingness
summary(ModT_an, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 75343 15069 3.891 0.0029 **
# species: Hybrids vs Parents 1 7920 7920 2.045 0.1558
# Residuals 100 387284 3873
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 1 observation deleted due to missingness
ModT_bp<-aov(branch_points ~ species, data=datT)
summary(ModT_bp)
summary(ModT_bp, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 796978 159396 5.100 0.000328 ***
# species: Hybrids vs Parents 1 76589 76589 2.451 0.120596
# Residuals 101 3156359 31251
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
ModT_ep<-aov(end_points ~ species, data=datT)
summary(ModT_ep)
summary(ModT_ep, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 88337 17667 3.823 0.00328 **
# species: Hybrids vs Parents 1 448 448 0.097 0.75631
# Residuals 100 462186 4622
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# 1 observation deleted due to missingness
############################################
########## Areole Area (uses dat2) #######
############################################
#for reference in table 1 used sqrt transformation:
hist(dat2$areole_area_new_mmsq)
hist(sqrt(dat2$areole_area_new_mmsq))
hist(log(dat2$areole_area_new_mmsq))
#subset data for individual analyses:
dat2B<-dat2[which(dat2$loc=="B"),]
sum(is.na(dat2B$species)) #0
nrow(dat2B) #21307
dat2M<-dat2[which(dat2$loc=="M"),]
sum(is.na(dat2M$species)) #0
nrow(dat2M) #19448
dat2T<-dat2[which(dat2$loc=="T"),]
sum(is.na(dat2T$species)) #0
nrow(dat2T) #15455
#histograms of subset data
hist(dat2B$areole_area_new_mmsq) #holy right skew
hist(sqrt(dat2B$areole_area_new_mmsq)) #better but...
hist(log(dat2B$areole_area_new_mmsq)) #much better!
hist(dat2M$areole_area_new_mmsq) #crazy right skew
hist(sqrt(dat2M$areole_area_new_mmsq)) #much better
hist(log(dat2M$areole_area_new_mmsq)) #better than raw, but sqrt might be best.
hist(dat2T$areole_area_new_mmsq) #pretty right-skewed as well
hist(sqrt(dat2T$areole_area_new_mmsq)) #better. Improves right skew
hist(log(dat2T$areole_area_new_mmsq)) #hard to say.. left skewed now
#set up contrasts
c1<-c(0,0,0,1,1,1)
mat<-cbind(c1)
contrasts(dat2B$species)<-mat
modB1<-aov(sqrt(areole_area_new_mmsq) ~ species, data=dat2B)
# summary(modB1, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 32.2 6.442 213.7 <2e-16 ***
# species: Hybrids vs Parents 1 5.3 5.346 177.3 <2e-16 ***
# Residuals 21301 642.2 0.030
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
c1<-c(0,0,0,1,1,1)
mat<-cbind(c1)
contrasts(dat2M$species)<-mat
dat2M$sqrt_aa<-sqrt(dat2M$areole_area_new_mmsq)
modM1<-aov(sqrt_aa ~ species, data=dat2M)
summary(modM1, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 40.7 8.131 244.43 < 2e-16 ***
# species: Hybrids vs Parents 1 1.0 0.987 29.68 5.17e-08 ***
# Residuals 19442 646.8 0.033
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
etaSquared(modM1)
# eta.sq eta.sq.part
# species 0.05914316 0.05914316
c1<-c(0,0,0,1,1,1)
mat<-cbind(c1)
contrasts(dat2T$species)<-mat
modT1<-aov(sqrt(areole_area_new_mmsq) ~ species, data=dat2T)
# summary(modT1, split=list(species=list("Hybrids vs Parents"=1)))
# Df Sum Sq Mean Sq F value Pr(>F)
# species 5 32.7 6.548 159.87 < 2e-16 ***
# species: Hybrids vs Parents 1 0.4 0.420 10.27 0.00136 **
# Residuals 15449 632.8 0.041
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
###########
rm(list=ls())
gc()
setwd("~")
library(psych)
library(GGally)
#data set with one line for each of B/M/T. Areole area is an average.
dat<-read.csv(file="AveragedBMT.csv") #has areole area (averaged for each location/leaf combo) but not LMA
dat2020<-read.csv("avgBMT2020.csv") #somehow areole area was removed from this one; probably because it's (typically) an unifomormative average. Has LMA
#remove some useless columns
dat<-dat[,c(2:11, 16:18, 28,29,31,35,39:45, 50:65)]
#add LMA
dat$LMA<-dat2020$LMA
#data from just leaf bases
datB<-dat[which(dat$loc=="B"),]
nrow(datB) #106
write.csv(file="DatB.csv", datB, row.names=FALSE)
#data from just leaf middles
datM<-dat[which(dat$loc=="M"),]
rownames(datM)<-c(1:nrow(datM))
write.csv(file="DatM.csv", datM, row.names=FALSE)
nrow(datM) #106
#data from just leaf apices (tips)
datT<-dat[which(dat$loc=="T"),]
rownames(datT)<-c(1:nrow(datT))
nrow(datT) #107
write.csv(file="DatT.csv", datT, row.names=FALSE)
#note that dataframes have different numbers of rows because of some missing data. These dataframes were recombined manually to account for missing data to generate CorsDat.csv
#load dataset for correlation matrices
cordat<-read.csv(file="CorsDat.csv")
nrow(cordat) #110
sum(is.na(cordat$species)) #2
cordat<-cordat[-c(which(is.na(cordat$species))),]
sum(is.na(cordat$species)) #0
nrow(cordat) #108
#reduce dataframe to only those variables that had either species or ploidy level effects in one-way ANOVAS (current MS, see above, or Baker et al 2017):
cordatred<-cordat[,c(1:19,22:28, 30:33,36,37,41,44,45,52:54)]
full<-corr.test(cordatred[,8:38])
print(full, short=FALSE) # lots of output; run this at your own risk.
corCI.out<-corCi(cordatred[,8:37], p=0.05)
corPlotUpperLowerCi(corCI.out)
cor.plot(cordatred[,8:37], scale=FALSE, cex=0.8, stars=TRUE, diag=FALSE)
cordatred$Category<-as.factor(cordatred$Category)
levels(cordatred$Category)<-strtrim(levels(cordatred$Category), 1)
cordatred$species<-as.factor(cordatred$species)
levels(cordatred$species)<-strtrim(levels(cordatred$species), 3)
cordatred$Category<-as.factor(cordatred$Category)
levels(cordatred$Category)<-strtrim(levels(cordatred$Category), 1)
pdf("parent_hybrid_test.pdf", h=15, w=15)
ggpairs(cordatred, columns=c(8:37), ggplot2::aes(colour=Category, alpha=0.5), cardinality_threshold=110, upper=list(continuous = wrap(cor.plot, r=cordatred[,8:37])), lower=list(continuous=wrap("points", alpha=0.3, size=0.1)))
dev.off()
pdf("species_test.pdf", h=15, w=15)
ggpairs(cordatred, columns=c(8:37), ggplot2::aes(colour=species, alpha=0.5), cardinality_threshold=110, upper=list(continuous = wrap("cor", size = 1)), lower=list(continuous=wrap("points", alpha=0.3, size=0.1)))
dev.off()
printVar = function(x,y){
vals = corr.test(x,y,
method="spearman")[c("estimate","p.value")]
vals[[1]]<-round(vals[[1]],2)
vals[[2]]<-ifelse(test = vals[[2]]<0.001,"<0.001",ifelse(test=vals[[2]]<0.01,"<0.01",round(vals[[2]],2)))
names(vals) = c("rho","p")
paste(names(vals),unlist(vals),collapse="\n")
}
my_fn <- function(data, mapping, ...){
# takes in x and y for each panel
xData <- eval_data_col(data, mapping$x)
yData <- eval_data_col(data, mapping$y)
colorData <- eval_data_col(data, mapping$colour)
mainCor = printVar(xData,yData)
p <- ggplot(data = data, mapping = mapping) +
annotate(x=0.5,y=0.8,label=mainCor,geom="text",size=3) +
geom_text(data=byGroup,inherit.aes=FALSE,
aes(x=x,y=y,col=col,label=label),size=3)+
theme_void() + ylim(c(0,1))
p
}
ggpairs(df[,-1],columns = 1:ncol(df[,-1]),
mapping=ggplot2::aes(colour = df$Group),
axisLabels = "show",
upper = list(continuous = my_fn))+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"))
attach(cordat)
dev.new()
pdf(file="baseRattempt.pdf", h=15, w=15)
pairs(cordat[,c(8:26)], diag.panel=panel.hist, lower.panel=rlb_plot, upper.panel=panel.cor_text, gap=0.3)
dev.off()
ggpairs(df[,-1],columns = 1:ncol(df[,-1]),
mapping=ggplot2::aes(colour = df$Group),legends = T,axisLabels = "show",
upper = list(continuous = wrap("cor", method = "spearman", size = 2.5, hjust=0.7)))+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"))
#https://www.thetopsites.net/projects/ggplot2/ggpairs.shtml
#GGally plots:
pdf("ggallytest.pdf", h=15, w=15)
ggpairs(cordat, columns=c(8:26), ggplot2::aes(colour=Category, alpha=0.5), cardinality_threshold=110)
dev.off()
pdf("parent_hybrid_test.pdf", h=15, w=15)
ggpairs(cordat, columns=c(8:26), ggplot2::aes(colour=Category, alpha=0.5), cardinality_threshold=110, upper=list(continuous = wrap("cor", size = 1)))
dev.off()
pdf("parent_hybrid_test1.pdf", h=15, w=15)
ggpairs(cordat, columns=c(8:26)
, ggplot2::aes(colour=Category, alpha=0.5), cardinality_threshold=110, upper=list(continuous = wrap("cor", title=NULL, size = 2)))
dev.off()
pdf("species_test.pdf", h=15, w=15)
ggpairs(cordat, columns=c(8:26), ggplot2::aes(colour=species, alpha=0.5), cardinality_threshold=110, upper=list(continuous = wrap("cor", size = 1)))
dev.off()
pdf("test.pdf", h=15, w=15)
ggpairs(cordat, columns=c(8:12), ggplot2::aes(colour=species, alpha=0.5), cardinality_threshold=110, upper=list(continuous = wrap("cor", size = 1)), p.adjust="bonferroni")
dev.off()
pdf("test_corrected.pdf", h=15, w=15) #p.adjust not actually doing anything.
ggpairs(cordat, columns=c(8:12), ggplot2::aes(colour=species, alpha=0.5, p.adjust="bonferroni"), cardinality_threshold=110, upper=list(continuous = wrap("cor", size = 1)))
dev.off()
ggpairs(cordat, columns=c(8:12), ggplot2::aes(colour=Category, alpha=0.5), cardinality_threshold=110, upper=list(continuous = wrap("cor", size = 3)))
#custom GGally correlation matrix with corrections for multiple testing.
## makes figure S1.
#adapted from:
#https://stackoverflow.com/questions/61686171/how-to-add-the-spearman-correlazion-p-value-along-with-correlation-coefficient-t
install.packages("ggExtra")
library(ggplot2)
library(GGally)
library(ggExtra)
library(data.table)
## read in data
cordat<-read.csv(file="CorsDat.csv")
nrow(cordat) #110
sum(is.na(cordat$species)) #2
cordat<-cordat[-c(which(is.na(cordat$species))),]
sum(is.na(cordat$species)) #0
nrow(cordat) #108
## reduce data set to just the pertinent info:
cordatred<-cordat[,c(1:19,22:28, 30:33,36,37,41,44,45,52:54)]
cordatred$Category<-as.factor(cordatred$Category)
levels(cordatred$Category)<-strtrim(levels(cordatred$Category), 1)
cordatred$species<-as.factor(cordatred$species)
levels(cordatred$species)<-strtrim(levels(cordatred$species), 3)
colnames(cordatred)<-c("Plant","concat","loc","Block", "ID","species","Category","adaxial","abaxial","ab:ad","B ends","M ends","A ends","B branch","M branch","A branch","B areole#","M areole#","A areole#","A skel","B areole area","M areole area","A areole area","B density","M density","A density","Photo","Cond","WUE","Fo","Fv","FvFm","Palisade","Spongey","Palisade:spongy","Leaf area","perimeter","dissection")
output<-data.frame()
printVar = function(x,y){
vals = cor.test(x,y,
method="pearson")[c("estimate","p.value")]
vals[[1]]<-round(vals[[1]],2)
vals[[2]]<-p.adjust(vals[[2]], method="holm")
vals[[2]]<-ifelse(test = vals[[2]]<0.001,"<0.001",ifelse(test=vals[[2]]<0.01,"<0.01",round(vals[[2]],2)))
names(vals) = c("r","p")
paste(names(vals),unlist(vals),collapse="\n")
}
my_fn <- function(data, mapping, ...){
# takes in x and y for each panel
xData <- eval_data_col(data, mapping$x)
yData <- eval_data_col(data, mapping$y)
colorData <- eval_data_col(data, mapping$colour)
# if you have colors, split according to color group and calculate cor
byGroup =by(data.frame(xData,yData),colorData,function(i)printVar(i[,1],i[,2]))
byGroup = data.frame(col=names(byGroup),label=as.character(byGroup))
byGroup$x = 0.5
byGroup$y = c(0.5, 0.1)
#byGroup$y = seq(0.8-0.3,0.2,length.out=nrow(byGroup))
#main correlation
mainCor = printVar(xData,yData)
p <- ggplot(data = data, mapping = mapping) +
annotate(x=0.5,y=0.9,label=mainCor,geom="text",size=1) +
geom_text(data=byGroup,inherit.aes=FALSE, lineheight=1,
aes(x=x,y=y,col=col,label=label),size=1)+
theme_void() + ylim(c(0,1))
p
}
pdf("S1.ParentHybrid_holm2023.pdf", h=15, w=15)
#### Parent is BLUE; Hybrid is RED
ggpairs(cordatred[,8:38],
mapping=ggplot2::aes(colour = cordatred$Category, alpha=0.5), cardinality_threshold=110,
lower = list(continuous=wrap("points", alpha=0.6, size=0.1)),
upper = list(continuous = my_fn))+
rotateTextX(angle = 90, hjust = 1, vjust = 0.5)+
theme(strip.background = element_rect(fill = "white"),panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.line=element_line(colour="black"), strip.text.x = element_text(size = 4), strip.text.y=element_text(size = 4)
)
dev.off()
####################################
##### Extract data from ggplot #####
####################################
g<-ggpairs(cordatred[,8:37],
mapping=ggplot2::aes(colour = cordatred$Category, alpha=0.5), cardinality_threshold=110,
lower = list(continuous=wrap("points", alpha=0.6, size=0.1)),
upper = list(continuous = my_fn))+
rotateTextX(angle = 90, hjust = 1, vjust = 0.5)+
theme(strip.background = element_rect(fill = "white"),panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.line=element_line(colour="black"), strip.text.x = element_text(size = 4), strip.text.y=element_text(size = 4)
)
library(stringr)
maincors<-data.frame(NULL)
for(m in 1:29){
for(j in (m+1):30){
l<-layer_data(g[m,j])
maincors<-rbind(maincors,l)
}
}
#results in a dataframe with 435 correlations coefficients & p values
split<-data.frame(str_split_fixed(maincors$label, " ", 3))
maincors<-cbind(maincors, split)
head(maincors$X3)
sum(maincors$X3==1) #0; if >0, will generate NAs in the next step
maincors$X3<-sub('.', '', maincors$X3) #removes first character from a string, essentially removes the "<" symbol (or anything else). So <0.001 becomes 0.001. >0.05 becomes 0.05 and 0.05 becomes .05. This is somewhat problematic as now it is not clear whether it is <0.05 of 0.05. Luckily there are no instances of "<0.05". So in this case, not a problem:
sum(split$X3=="0.05")
#[1] 5
sum(split$X3=="<0.05")
#[1] 0
maincors$X3<-as.numeric(maincors$X3)
sum(maincors$X3<0.05) #215
ph_cors<-data.frame(NULL)
for(m in 1:29){
for(j in (m+1):30){
l<-layer_data(g[m,j], i=2L)
l$yaxis<-g$yAxisLabel[m] #axis labels of correlations
l$xaxis<-g$xAxisLabel[j] #axis labels of correlations
ph_cors<-rbind(ph_cors,l)
}
}
#results in a dataframe with 870 correlation coefficients & p values
# color #F8766D is the hybrid (pale orange)
# color #00BFC4 is the parent (pale blue)
head(ph_cors)$label # gives r & p values
split2<-data.frame(str_split_fixed(ph_cors$label, " ",3))
sum(split2$X3=="0.05") #15
sum(split2$X3=="<0.05") #0 noice.
sum(split2$X3=="1") #2; these will generate NAs and will need to be dealt with individually.
ph_cors<-cbind(ph_cors, split2)
ph_cors$X3<-sub('.', '', ph_cors$X3) #gets rid of first character in string (often <)
ph_cors$X3<-as.numeric(ph_cors$X3)
sum(is.na(ph_cors$X3)) #2 These need to become "1".
ph_cors[813,19] #NA
ph_cors[813,19]<-1
ph_cors[813,19] #1
which(is.na(ph_cors$X3)) #106
ph_cors[106,19] #NA
ph_cors[106,19] <-1
ph_cors[106,19] #1
sum(is.na(ph_cors$X3)) #0
parents<-ph_cors[which(ph_cors$colour=='#00BFC4'),]
hybrids<-ph_cors[which(ph_cors$colour=='#F8766D'),]
nrow(parents)#435
nrow(hybrids)#435
colnames(parents)[19]<-"parent.p"
colnames(hybrids)[19]<-"hybrid.p"
p.values<-data.frame(parents$yaxis, parents$xaxis, parents$parent.p, hybrids$hybrid.p)
colnames(p.values)<-c("yaxis", "xaxis", "parent.p", "hybrid.p")
p.values$all.p<-maincors$X3
p.values$parent.p<-as.numeric(p.values$parent.p)
p.values$hybrid.p<-as.numeric(p.values$hybrid.p)
sum(p.values$parent<0.05) #181
sum(p.values$hybrid<0.05) #204
p.values$h<-p.values$hybrid<0.05
p.values$p<-p.values$parent<0.05
p.values$a<-p.values$all.p<0.05
p.values$sum<-p.values$h+p.values$p+p.values$a
head(p.values)
sum(p.values$sum==3) #166 - the number of correlations where P&H sig - no change in pheno integration
hsig<-p.values[which(p.values$hybrid.p<0.05 & p.values$parent.p>=0.05),]
nrow(hsig) #38; the number where parent is nonsig and hybrid is sig (gain of pheno integration)
psig<-p.values[which(p.values$hybrid.p>=0.05 & p.values$parent.p<0.05),]
nrow(psig) #15; the number where parent is sig and hybrid is non-sig (loss of pheno integration)
435-38-15 #382 - the number of correlations where there was no state change, irregardless of whehther they were sig or non-sig.
###############################################################
###### determine which (if any) traits are over-represented in correlations where phenotypic integratin changes "status" between diploid parents and allotetraploid hybrids ###########
###############################################################
############### find the frequency that each trait participates in a state-change, convert to Z-scale, and then find sig. difference.
### Issues: 1) clearly non-normal distribution (so did a log transformation, but still not awesome) 2) performed a one-tailed test but not super happy with it.
sigplayers<-c(unlist(hsig$yaxis), unlist(hsig$xaxis), unlist(psig$yaxis), unlist(psig$xaxis)) #list of all traits involved in state changes and the number of times they are listed corresponds to the number of state changes they are involved in.
length(sigplayers) #106
tab<-data.frame(table(sigplayers))
tab
# sigplayers Freq
# 1 A areole area 2
# 2 A areole# 2
# 3 A branch 2
# 4 A density 5
# 5 A ends 5
# 6 A skel 2
# 7 ab:ad 7
# 8 abaxial 3
# 9 adaxial 2
# 10 B areole area 3
# 11 B areole# 1
# 12 B branch 1
# 13 B density 3
# 14 B ends 1
# 15 Cond 3
# 16 Fo 1
# 17 Fv 1
# 18 FvFm 4
# 19 Leaf area 15
# 20 M areole area 3
# 21 M areole# 4
# 22 M branch 3
# 23 M density 2
# 24 M ends 3
# 25 Palisade 8
# 26 Palisade:spongy 4
# 27 perimeter 2
# 28 Photo 3
# 29 Spongey 10
# 30 WUE 1
# interesting that all traits were involved in at least 1 state change.
hist(tab$Freq) # highly left-skewed
dev.new()
hist(log(tab$Freq))#better
dev.new()
hist(sqrt(tab$Freq))#nope.
tab$log<-log(tab$Freq) #log transform improves normality...still not normal.
sd(tab$log) #[1] 0.7095751
mean(tab$log) #[1] 1.001822