-
Notifications
You must be signed in to change notification settings - Fork 0
/
significance.Rmd
696 lines (485 loc) · 21.9 KB
/
significance.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
---
title: "Biological Significance"
author: "Tina Lasisi"
date: "`r Sys.time()`"
output:
workflowr::wflow_html:
toc: yes
number_sections: yes
pdf_document: default
editor_options:
chunk_output_type: console
---
```{r setup, message=FALSE, warning=FALSE, include=FALSE, paged.print=FALSE}
library(tidyverse)
library(knitr)
library(cowplot)
F = rprojroot::is_rstudio_project$make_fix_file()
knitr::opts_chunk$set(echo = FALSE, include = TRUE, eval = TRUE, warning = FALSE, message = FALSE, fig.retina = 2, fig.width = 8, fig.height = 4, out.width = "100%")
```
```{r functions, include=FALSE}
plot_path = F("output/")
pltsave_func <- function(plot, plot_path, width, height){
ggsave(
filename = paste0(deparse(substitute(plot)), ".png"),
plot = plot,
path = plot_path,
width = width,
height = height)
plot(plot)
}
```
```{r read_df_admixed, include=FALSE}
df_admixed <- read_csv(F("data/df_Admixed_Merged.csv"))
colnames(df_admixed)[c(18:22)] = c("SAS","AMR","EUR","AFR","EAS")
```
To explore the significance of quantifying hair fiber morphology, we explore the relationship between various quantitative hair traits, categorical data and genotype data on the same sample.
```{r df_admixed_plt, include=FALSE}
df_admixed_plt <- df_admixed %>%
group_by(ID, hair_texture, HairTypeBin, sex, age) %>%
summarize(area_mean = mean(area),
area_median = median(area),
min_mean = mean(min),
max_mean = mean(max),
min_median = median(min),
max_median = median(max),
eccentricity_mean = mean(eccentricity),
eccentricity_median = median(eccentricity),
curv_median = mean(curv_median),
curv_mean = mean(curv_mean),
length_mean = mean(length_mean),
length_median = mean(length_median),
SAS = mean(SAS),
AMR = mean(AMR),
EUR = mean(EUR),
AFR = mean(AFR),
EAS = mean(EAS),
hair_count = mean(hair_count),
m_index = mean(m_index)) %>%
mutate(hair_texture = str_to_title(hair_texture)) %>%
filter(hair_count > 4 & AFR > 0.1)
df_admixed_plt$hair_texture <- factor(df_admixed_plt$hair_texture,
levels = c("Straight","Wavy",
"Curly",
"Very Curly",
NA))
df_admixed_plt$HairTypeBin <- factor(df_admixed_plt$HairTypeBin,
levels = c("Straight","Wavy",
"Curly",
"Very Curly"))
# I filtered out anyone who had less than 5 hair fragments and I only kept the "first" reported ethnicity to make sure I didn't have duplicates of IDs
```
Our data consists of 193 individuals for whom we have quantitative hair phenotype data. In our first data quality control step, we filter to keep individuals who have more than 4 hair fragments in their curvature image and over 10% African ancestry. We calculate mean and median values for the cross-sectional data we have collected for individuals (~ 6 sectioned hair fibers). In our analyses, we use median values as they are less affected by intra-individual outliers.
# Self-reported hair texture vs. quantitative hair curvature
We compare the self-reported hair texture with mean and median curvature for our sample.
```{r plt_admixed_SelfRepHair, fig.height=4, fig.width=8, fig.cap= "Self-reported hair texture vs. quantitative hair curvature"}
plt_admixed_SelfRepHair_CurvMean <- df_admixed_plt %>%
filter(is.na(hair_texture)=="FALSE")%>%
ggplot(., aes(hair_texture,
curv_mean))+
geom_violin(fill="#a6bddb",
scale = "width")+
geom_point(position = position_jitter(width=0.1),
alpha = 0.4)+
theme(axis.text.x = element_text(angle=90))+
labs(x = "Self reported hair texture",
y = bquote("Mean curvature ("*mm^-1*")"),
title = "Quantitative variation underlying \n self reported hair texture (mean)")+
theme_bw() +
coord_flip()
plt_admixed_SelfRepHair_CurvMedian <- df_admixed_plt %>%
filter(is.na(hair_texture)=="FALSE")%>%
ggplot(., aes(hair_texture,
curv_median))+
geom_violin(fill="#a6bddb",
scale = "width")+
geom_point(position = position_jitter(width=0.1),
alpha = 0.4)+
theme(axis.text.x = element_text(angle=90))+
labs(x = "Self reported hair texture",
y = bquote("Median curvature ("*mm^-1*")"),
title = "Quantitative variation underlying \n self reported hair texture (median)")+
theme_bw() +
coord_flip()
plt_SelfRepCurv <- plot_grid(plt_admixed_SelfRepHair_CurvMean,
plt_admixed_SelfRepHair_CurvMedian, labels = c("a", "b"))
plt_SelfRepCurv
```
The single individual with a high mean curvature in the straight group is the result of an artefact in the image.
```{r artefact_im, fig.cap= "Image of hair sample with artefact biasing the measurement"}
# knitr for PDF document
# knitr::include_graphics("../docs/assets/artefact.jpg", error = FALSE)
# knitr for workflowr HTML
knitr::include_graphics("assets/artefact.jpg", error = FALSE)
```
The red arrow points to a stray fiber that likely contaminated the sample and was missed during imaging. Such potential outliers are the reason we chose to use the median curvature for a sample in our analyses.
# Objective hair texture classification vs. quantitative curvature
To explore how much data is lost when binning continuous variation, we compared mean and median curvature to classified hair texture. This classification is based on Loussouarn et al.'s 2007 paper ["Worldwide diversity of hair curliness: a new method of assessment](https://doi.org/10.1111/j.1365-4632.2007.03453.x).
While the authors propose a number of parameters to distinguish curlier hair types (based on number of twists and waves among other factors), their primary classification is based on curvature. We demonstrate that, regardless of additional parameters, a considerable range of curvature is obscured when collapsing hair variation according to their curvature thresholds.
```{r plt_admixed_HairTypeBin, fig.cap= "Objective hair classification vs. quantitative curvature"}
plt_admixed_HairTypeBin_CurvMean <- df_admixed_plt %>%
mutate(HairTypeBin_mean =
factor(case_when(
curv_mean<= (1/54) ~ 'Straight',
curv_mean<= (1/28.5) ~ 'Wavy',
curv_mean<= (1/6) ~ 'Curly',
TRUE ~ 'Very Curly'),
levels = c("Straight", "Wavy", "Curly", "Very Curly"))) %>%
ggplot(., aes(HairTypeBin_mean,
curv_mean))+
geom_violin(fill="#a6bddb", scale = "width")+
geom_point(position = position_jitter(width=0.1),
alpha = 0.4)+
theme(axis.text.x = element_text(angle=90))+
labs(x = "Classified hair texture \n(based on median curvature)",
y = bquote("Mean curvature ("*mm^-1*")")) +
theme_bw() +
coord_flip()
plt_admixed_HairTypeBin_CurvMedian <- df_admixed_plt %>%
mutate(HairTypeBin_median =
factor(case_when(
curv_median<= (1/54) ~ 'Straight',
curv_median<= (1/28.5) ~ 'Wavy',
curv_median<= (1/6) ~ 'Curly',
TRUE ~ 'Very Curly'), levels = c("Straight", "Wavy", "Curly", "Very Curly"))) %>%
ggplot(., aes(HairTypeBin_median,
curv_median))+
geom_violin(fill="#a6bddb", scale = "width")+
geom_point(position = position_jitter(width=0.1),
alpha = 0.4)+
theme(axis.text.x = element_text(angle=90))+
labs(x = "Classified hair texture \n(based on median curvature)",
y = bquote("Median curvature ("*mm^-1*")"))+
theme_bw() +
coord_flip()
plt_HairBin <- plot_grid(plt_admixed_HairTypeBin_CurvMean,
plt_admixed_HairTypeBin_CurvMedian, labels = c("a", "b"))
plt_HairBin
```
```{r imsave_QualQuant, include=FALSE}
# Saving different images for manuscript
plt_QualQuant_CurvMedian <- plot_grid((plt_admixed_SelfRepHair_CurvMedian + ggtitle(" Median curvature vs. \nSelf-reported hair texture")), (plt_admixed_HairTypeBin_CurvMedian + ggtitle("Median curvature vs. \nClassified hair texture")), labels = c("a", "b"))
pltsave_func(plt_QualQuant_CurvMedian, plot_path, width = 8, height = 4)
```
# Ancestry vs. hair morphology
We carried out a number of analyses using the genotype data collected for this diverse sample. In an admixed sample where a continuous trait has divergent distributions in the parental ancestry groups, the resulting admixed population can show a correlation between ancestry and that trait. Finding such a correlation suggests may imply a polygenic trait with high heritability.
## Admixture components
Our sample consists of admixed individuals with primarily African and European ancestry.
```{r plt_admixture, fig.height=5, fig.width=10, fig.cap= "Admixture components for sample"}
anc <- df_admixed_plt %>%
ungroup() %>%
select(ID, SAS, AMR, AFR, EUR, EAS) %>%
arrange(AFR)
anc$ID <- factor(anc$ID, levels = anc$ID)
manc = reshape2::melt(anc, id.vars="ID")
plt_manc = ggplot(manc)+
geom_bar(aes(ID,value, fill=variable),
stat = "identity",
width=1)+
theme_bw()+
theme(axis.text.x = element_blank(),
axis.ticks.x = element_blank())+
labs(x = "Individuals",
y = "Ancestry",
fill = "Population")+
scale_fill_manual(values = c(
"#e41a1c",
"#377eb8",
"#4daf4a",
"#984ea3",
"#ff7f00"
))
plt_manc
```
The colors represent ancestries that correspond to the following 1000 Genomes populations:
- SAS = South Asian
- AMR = American
- AFR = African
- EUR = European
- EAS = East Asian
Each of these are metapopulations based on the grouping of multiple (sub)continental population groups in the [1000 Genomes repository](https://www.internationalgenome.org/category/population/).
## Ancestry vs. curvature
Here we plot the correlation between proportion of African ancestry and m-index, median curvature, and eccentricity.
```{r stats_anc_corr, include=FALSE}
r2_mindex_afr = with(df_admixed_plt, cor(AFR, m_index,
use = "complete.obs"))
r2_mindex_afr
r2_curv_afr = with(df_admixed_plt, cor(AFR, curv_median))
r2_curv_afr
r2_ecc_afr = with(df_admixed_plt, cor(AFR, eccentricity_median,
use = "complete.obs"))
r2_ecc_afr
```
```{r plt_anc_corr, fig.height=10, fig.width=7, fig.cap= "Percentage of African ancestry vs. M-index, curvature and eccentricity"}
plt_mindex_afr = ggplot(df_admixed_plt,
aes(AFR, m_index))+
geom_point(alpha = 0.7)+
stat_smooth(method = "lm")+
theme_classic()+
labs(x = "African Ancestry",
y = bquote("Melanin index"))+
annotate(geom="text",x = 0.2, y = 70,
label = bquote(r^2*" = 0.83"))
plt_curv_afr = ggplot(df_admixed_plt,
aes(AFR, curv_median))+
geom_point(alpha = 0.7)+
stat_smooth(method = "lm")+
theme_classic()+
labs(x = "African Ancestry",
y = bquote("Median curvature ("*mm^-1*")"))+
annotate(geom="text",x = 0.2, y = 0.7,
label = bquote(r^2*" = 0.85"))
plt_ecc_afr = ggplot(df_admixed_plt,
aes(AFR, eccentricity_median))+
geom_point(alpha = 0.7)+
stat_smooth(method = "lm")+
theme_classic()+
labs(x = "African Ancestry",
y = bquote("Eccentricity"))+
annotate(geom="text",x = 0.3, y = 0.5,
label = bquote(r^2*" = 0.56"))
plt_trait_afr <- plot_grid(plt_mindex_afr, plt_curv_afr, plt_ecc_afr, labels = c("a", "b", "c"), nrow = 3, ncol = 1)
plt_trait_afr
```
## Curvature vs. eccentricity
The relationship between cross-sectional shape (eccentricity) and curvature has long been debated. Due to the coincidence of cross-sectional shape and curvature in various populations that are often contrasted (i.e. East Asian vs. North European vs. West African), it has been unclear whether these traits have a causal relationship (specifically that higher eccentricity predicts higher curvature). In our admixed sample, we have the opportunity to test this question and fit a model between these traits with and without ancestry.
```{r df_curv_ecc}
df_curv_ecc = df_admixed_plt %>%
ungroup() %>%
select(curv_median, eccentricity_median, AFR)%>%
drop_na()
```
### Uncorrected
First we examine the data without correcting for ancestry.
```{r stats_curv_ecc}
lcurv_ecc.1 = lm(data = df_curv_ecc,
curv_median ~ eccentricity_median)
summary(lcurv_ecc.1)
plot(lcurv_ecc.1)
```
```{r plt_curv_ecc, fig.cap= "Curvature vs. eccentricity (without correction for ancestry)"}
evc1 = ggplot(df_curv_ecc, aes(eccentricity_median,
curv_median))+
geom_point()+
theme_classic()+
stat_smooth(method="lm")+
labs(y = "Curvature",
x = "Eccentricity (median)",
title = "Curvature vs eccentricity \n (ancestry uncorrected)")+
annotate(geom = "text",
x = 0.4, y = 0.4, hjust = 0,
label = "p-value = 1.96e-08")+
ylim(c(0.01,0.8))
evc1
```
The residual plots show that there might be a few problems with the relationship:
1. possibly an outlier distorting the relationship,
2. relationship might not be linear
3. errors might be heteroescedastic.
Let's refit the model after removing the outlier.
```{r}
df_curv_ecc = df_curv_ecc %>%
filter(eccentricity_median > 0.4)
lcurv_ecc.1 = lm(data = df_curv_ecc,
curv_median ~ eccentricity_median)
summary(lcurv_ecc.1)
plot(lcurv_ecc.1)
```
Next, let's see if the data fits a quadratic model better.
```{r}
df_curv_ecc = df_curv_ecc%>%
mutate(eccentricity_median2 = eccentricity_median^2)
lcurv_ecc.1.1 = lm(data = df_curv_ecc,
curv_median ~ eccentricity_median + eccentricity_median2)
anova(lcurv_ecc.1, lcurv_ecc.1.1, test = "Chisq")
plot(lcurv_ecc.1.1)
```
Finally, let's use the fitted values as weights in a weighted regression. Because the variance increases with increasing eccentricity, we will use 1/fitted_values^2 as weights.
```{r}
#weights
df_curv_ecc$inv.curv = 1/lcurv_ecc.1.1$fitted.values^2
lcurv_ecc.1.2 = lm(data = df_curv_ecc,
curv_median ~ eccentricity_median +
eccentricity_median2,
weights = inv.curv)
summary(lcurv_ecc.1.2)
plot(lcurv_ecc.1.2)
```
Now the residuals look a lot better so we will go with this model. Let's generate the scatterplot with the model fit.
```{r}
df_curv_ecc$fitted.cve = lcurv_ecc.1.2$fitted.values
# r2_cve = paste("r^2 ~", round(summary(lcurv_ecc.1.2)$r.squared, 2))
pvalue_cve1 = round(summary(lcurv_ecc.1.2)$coefficients[2,4],4)
pvalue_cve2 = round(summary(lcurv_ecc.1.2)$coefficients[3,4],4)
plt_cve = ggplot(df_curv_ecc,
aes(eccentricity_median,
curv_median)) +
geom_point()+
theme_classic()+
labs(y = "Curvature",
x = "Eccentricity (median)",
title = "Curvature vs eccentricity \n (ancestry uncorrected)")+
annotate(geom = "text",
x = 0.5, y = 0.7, hjust = 0,
label = paste("pvalue (eccentricity):",
pvalue_cve1))+
annotate(geom = "text",
x = 0.5, y = 0.6, hjust = 0,
label = paste("pvalue (eccentricity^2):",
pvalue_cve2))+
ylim(c(0.01,0.8)) +
geom_line(aes(eccentricity_median, fitted.cve),
color = "red")
plt_cve
```
If we consider the relationship between curvature and eccentricity without taking into account ancestry, we find that eccentricity is a significant predictor of curvature.
### Corrected
We then re-plot the relationship after residualizing curvature and eccentriciy (both) on ancestry.
```{r plt_curv_ecc_anc, fig.cap= "Curvature vs. eccentricity (with correction for ancestry)"}
lcurv_afr = lm(data = df_curv_ecc,
curv_median ~ AFR)
lecc_afr = lm(data = df_curv_ecc,
eccentricity_median ~ AFR)
#turns out the correlation between curvature and eccentricity is due to stratification.
df_curv_ecc = df_curv_ecc %>%
mutate(resid_cvafr = resid(lcurv_afr),
resid_evafr = resid(lecc_afr))
evc2 = ggplot(df_curv_ecc,
aes(resid_evafr,
resid_cvafr))+
geom_point()+
theme_classic()+
stat_smooth(method="lm")+
labs(y = "Curvature (ancestry corrected)",
x = "Eccentricity (ancestry corrected)",
title = "Curvature vs eccentricity \n (ancestry corrected)")
evc2
```
However, when we correct for ancestry, this correlation is no longer significant. This supports the idea that these traits may be independent. Let's fit a formal model here.
The relationship looks rather linear so let's start with a simple linear model and inspect the residuals.
```{r}
lcve_corrected = lm(data = df_curv_ecc,
curv_median ~ eccentricity_median + AFR)
summary(lcve_corrected)
plot(lcve_corrected)
```
The relationship looks pretty linear but there's still some heteroescedasticity in the residuals. We will fit a weighted regression model.
```{r}
df_curv_ecc$fitted.cve_afr = 1/fitted(lcve_corrected)^2
lcve_corrected.1 = lm(data = df_curv_ecc,
curv_median ~ eccentricity_median + AFR, weights = fitted.cve_afr)
summary(lcve_corrected.1)
plot(lcve_corrected.1$fitted.values, rstandard(lcve_corrected.1),
xlab = "Fitted values",
ylab = "Standardized residuals")
```
The weighted regression corrects the heteroescedasticity well.
```{r}
df_curv_ecc$fitted.cve_afr.weighted = fitted(lcve_corrected.1)
pvalue_cve.corrected = round(summary(lcve_corrected.1)$coefficients[2,4],2)
evc2.1 = ggplot(df_curv_ecc,
aes(resid_evafr,
resid_cvafr))+
geom_point()+
theme_classic()+
labs(y = "Curvature (ancestry corrected)",
x = "Eccentricity (ancestry corrected)",
title = "Curvature vs eccentricity \n (ancestry corrected)")+
stat_smooth(method = "lm", se = FALSE, color = "red")+
annotate(geom = "text",
x = -0.25, y = 0.2, hjust = 0,
label = paste("pvalue (eccentricity):", pvalue_cve.corrected))
evc2.1
```
## Curvature vs. skin pigmentation
To demonstrate the potential effect of population stratification on traits, we compare hair curvature with skin pigmentation (m-index). These two traits are not biologically related, yet, in an admixed population, we may see a correlation that is due to population stratification of these polygenic traits.
### Uncorrected
First we examine the relationship between curvature and skin pigmentation without correcting for ancestry.
```{r stats_curv_mindex}
df_curv_mindex = df_admixed_plt %>%
ungroup() %>%
select(curv_median, m_index, AFR)%>%
drop_na()
lcurv_mindex.1 = lm(data = df_curv_mindex,
curv_median ~ m_index)
summary(lcurv_mindex.1)
plot(lcurv_mindex.1)
```
```{r plt_curv_mindex, fig.cap= "Curvature vs. M-index (without correction for ancestry)"}
mvc_uncorrected = ggplot(df_curv_mindex,
aes(m_index,
curv_median))+
geom_point()+
theme_classic()+
labs(x = "Melanin index",
y = "Curvature",
title = "Curvature vs melanin index \n (ancestry uncorrected)")+
stat_smooth(method="lm")+
annotate(geom = "text",
x = 50, y = 0.15,
label = "p-value < 2e-16")
mvc_uncorrected
```
As expected, we see a significant correlation between the two traits. The relationship appears to be linear. There still seems to be more variance for observations with higher melanin index/curvature. We will use a weighted regression approach again.
```{r}
df_curv_mindex$weights_cvm = 1/lcurv_mindex.1$fitted.values^2
lcurv_mindex.2 = lm(data = df_curv_mindex,
curv_median ~ m_index,
weights = weights_cvm)
summary(lcurv_mindex.2)
plot(fitted(lcurv_mindex.2),
rstandard(lcurv_mindex.2),
xlab = "Fitted values",
ylab = "Standardized residuals")
```
That fixes the heteroescedasticity issue.
```{r}
pvalue_cvm.weighted = formatC(summary(lcurv_mindex.2)$coefficients[2,4])
mvc_uncorrected = ggplot(df_curv_mindex,
aes(m_index,
curv_median))+
geom_point()+
theme_classic()+
labs(x = "Melanin index",
y = "Curvature",
title = "Curvature vs melanin index \n (ancestry uncorrected)")+
stat_smooth(method="lm", color = "red", se = FALSE)+
annotate(geom = "text",
x = 50, y = 0.15, hjust = 0,
label = paste("pvalue (MIndex):",
pvalue_cvm.weighted))
mvc_uncorrected
```
### Corrected
We then apply a correction for ancestry and re-analyze the data.
```{r stats_curv_mindex_anc}
lcurv_afr.2 = lm(data = df_curv_mindex,
curv_median ~ AFR)
lmindex_afr = lm(data = df_curv_mindex,
m_index ~ AFR)
df_curv_mindex = df_curv_mindex %>%
mutate(resid_cvafr = resid(lcurv_afr.2),
resid_miafr = resid(lmindex_afr))
lmindex_curv = lm(data = df_curv_mindex,
curv_median ~ m_index + AFR,
weights = weights_cvm)
pvalue_cvm.corrected = round(summary(lmindex_curv)$coefficients[2,4],3)
mvc_corrected = ggplot(df_curv_mindex,
aes(resid_miafr,
resid_cvafr))+
geom_point()+
theme_classic()+
labs(x = "Melanin index (ancestry corrected)",
y = "Curvature (ancestry corrected)",
title = "Curvature vs melanin index \n(ancestry corrected)")+
stat_smooth(method="lm",se = FALSE, color = "red")+
annotate(geom = "text",
x = 0, y = -0.3,
label = paste("pvalue (MIndex):", pvalue_cvm.corrected))
mvc_corrected
```
Like with curvature and eccentricity, the relationship between curvature and skin pigmentation is no longer significant when ancestry is taken into account.
```{r imsave_mvc_evc_combo, include=FALSE}
plt_strat <- plot_grid(mvc_uncorrected, mvc_corrected, plt_cve, evc2.1, labels = c("a", "b", "c", "d"), nrow = 2, ncol = 2)
pltsave_func(plt_strat, plot_path, width = 8, height = 8)
```