Skip to content

Commit af46c68

Browse files
committed
Fix vignette
1 parent bd771b5 commit af46c68

3 files changed

Lines changed: 37 additions & 32 deletions

File tree

doc/superadmixture.Rmd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ data("fam_amr", package = "superadmixture")
234234

235235
Since the number of loci of the AMR subset of 1000 Genomes dataset is too large for a quick analysis, we created a subset of this dataset by first applying allele frequency filters and LD-pruning to the AMR dataset. We then randomly selected 10,000 SNPs out of LD-pruned SNP sets. We also re-ordered individuals according to their pairwise kinship level. This subset is available in `data/X_amr.rda`. This data has `r nrow(X_amr)` individuals and `r ncol(X_amr)` loci. The associated fam file can be found in `data/fam_amr.rda`. These data can be reproduced by scripts `data-raw/{amr.bash,amr.R}`.
236236

237-
We adopt the `popkin` package to obtain the Ochoa-Storey (OS) estimate of coancestry among individuals. The following chunk of the code estimates the individual-level coancestry according to the Ochoa-Storey (OS) method by `popkin` package. It should noted that the `popkin` function returns the kinship coefficients instead of the coancestry coefficients. Therefore, we use the `inbr_diag` function in the `popkin` package to map kinship coefficients $\phi_{jk}$'s to coancestry coefficients $\theta_{jk}$'s:
237+
We adopt the `popkin` package to obtain the Ochoa-Storey (OS) estimate of coancestry among individuals. The following chunk of the code estimates the individual-level coancestry $\hat{\boldsymbol{\Theta}}^{\text{OS}}$ according to the Ochoa-Storey (OS) method by `popkin` package. It should noted that the `popkin` function returns the kinship coefficients instead of the coancestry coefficients. Therefore, we use the `inbr_diag` function in the `popkin` package to map kinship coefficients $\phi_{jk}$'s to coancestry coefficients $\theta_{jk}$'s:
238238

239239
\[
240240
\theta_{jk} =
@@ -308,7 +308,7 @@ legend_color_categories(colors = colors_subpops, categories = subpop_order, labe
308308

309309
## Estimating admixture proportions and coancestry among antecedent populations
310310

311-
The following chunk of the code estimates the admixture proportions $\bQ$ from genotypes. We first estimate the individual specific allele frequencies $\boldsymbol{\Pi}$ using the `est_p_indiv` function in the `superadmixture` package. We then estimate $\bQ$ by decomposing $\boldsymbol{\Pi}$ with `factor_p_indiv` function in the `superadmixture` package.
311+
The following chunk of the code estimates the admixture proportions $\bQ$ from genotypes. We first estimate the individual specific allele frequencies $\boldsymbol{\Pi}$ using the `est_p_indiv` function in the `superadmixture` package. We then estimate $\bQ$ by decomposing $\boldsymbol{\Pi}$ with `factor_p_indiv` function in the `superadmixture` package.
312312

313313
```{r estimate_admix_props_amr, eval=!fast_run, message=FALSE, warning=FALSE}
314314
library(superadmixture)
@@ -323,7 +323,7 @@ obj <- factor_p_indiv(p_indiv, k_antepops = 3, rowspace = rowspace, verbose = FA
323323
Q_hat <- obj$Q_hat
324324
```
325325

326-
After obtaining individual-level coancestry `coanc_indiv` and admixture proportions `Q_hat`, we can use the function `est_coanc` to estimate population coancestry under the super admixture model and under the standard admixture model.
326+
After obtaining individual-level coancestry `coanc_indiv` and admixture proportions `Q_hat`, we can use the function `est_coanc` to estimate population coancestry $\boldsymbol{\Lambda}$ under the super admixture model and under the standard admixture model. In our manuscript, `coanc_pops_sup` is denoted as $\hat{\boldsymbol{\Lambda}}^{\text{sup}}$ and `coanc_pops_std` is denoted as $\hat{\boldsymbol{\Lambda}}^{\text{std}}$.
327327

328328
```{r estimate_coanc_pops_amr, eval=!fast_run, message=FALSE, warning=FALSE}
329329
# estimate population coancestry under the super admixture model
@@ -381,7 +381,7 @@ heatmap_coanc_antepops(coanc_pops_sup, tl.offset = 1)
381381

382382
## Calculating the individual-level coancestry under the super admixture and standard admixture
383383

384-
We then obtain the corresponding individual-coancestry under the super admixture model and under the standard admixture model.
384+
We then obtain the corresponding individual-coancestry under the super admixture model and under the standard admixture model. In our manuscript, `coanc_sup` is denoted as $\hat{\boldsymbol{\Theta}}^{\text{sup}}$ and `coanc_std` is denoted as $\hat{\boldsymbol{\Theta}}^{\text{std}}$.
385385

386386
```{r estimate_coanc_supadmix_stdadmix_amr, eval=!fast_run, message=FALSE, warning=FALSE}
387387
coanc_sup <- t(Q_hat) %*% coanc_pops_sup %*% Q_hat
@@ -489,7 +489,7 @@ kinship <- ifelse(kinship< 0, 0, kinship)
489489
coanc_indiv <- ifelse(coanc_indiv < 0, 0, coanc_indiv)
490490
```
491491

492-
We can visualize the individual-level coancestry of the simulated data using `plot_popkin` function in the `popkin` function. We use the following helper function `plot_colors_subpops` to label the sub-populations.
492+
We can visualize the individual-level coancestry of the simulated data using `plot_popkin` function in the `popkin` package. We use the following helper function `plot_colors_subpops` to label the sub-populations.
493493

494494
```{r}
495495
plot_colors_subpops <- function(pops, srt = 0, cex = 0.6, y = FALSE) {
@@ -538,7 +538,7 @@ obj <- factor_p_indiv(p_indiv, k_antepops = 7, rowspace = rowspace, verbose = FA
538538
Q_hat <- obj$Q_hat
539539
```
540540

541-
After obtaining individual-level coancestry `coanc_indiv` and admixture proportions `Q_hat`, we can use the function `est_coanc` to estimate population coancestry under the super admixture model and under the standard admixture model. The output `coanc_pops_sup` is the coancestry of antecedent populations $\boldsymbol{\Lambda}$ in our manuscript.
541+
After obtaining individual-level coancestry `coanc_indiv` and admixture proportions `Q_hat`, we can use the function `est_coanc` to estimate population coancestry $\boldsymbol{\Lambda}$ under the super admixture model and under the standard admixture model. In our manuscript, `coanc_pops_sup` is denoted as $\hat{\boldsymbol{\Lambda}}^{\text{sup}}$ and `coanc_pops_std` is denoted as $\hat{\boldsymbol{\Lambda}}^{\text{std}}$.
542542

543543
```{r estimate_coanc_antepops_hgdp, eval=!fast_run, message=FALSE, warning=FALSE}
544544
# estimate population coancestry under the super admixture model
@@ -606,7 +606,7 @@ heatmap_coanc_antepops(coanc_pops_sup, tl.offset = 1)
606606

607607
## Calculating individual-level coancestry under the super admixture and standard admixture
608608

609-
We then obtain the corresponding individual-coancestry under the super admixture model and under the standard admixture model.
609+
We then obtain the corresponding individual-coancestry under the super admixture model and under the standard admixture model. In our manuscript, `coanc_sup` is denoted as $\hat{\boldsymbol{\Theta}}^{\text{sup}}$ and `coanc_std` is denoted as $\hat{\boldsymbol{\Theta}}^{\text{std}}$.
610610

611611
```{r estimate_coanc_supadmix_stdadmix_hgdp, eval=!fast_run, message=FALSE, warning=FALSE}
612612
coanc_sup <- t(Q_hat) %*% coanc_pops_sup %*% Q_hat

doc/superadmixture.html

Lines changed: 23 additions & 18 deletions
Large diffs are not rendered by default.

vignettes/superadmixture.Rmd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ data("fam_amr", package = "superadmixture")
234234

235235
Since the number of loci of the AMR subset of 1000 Genomes dataset is too large for a quick analysis, we created a subset of this dataset by first applying allele frequency filters and LD-pruning to the AMR dataset. We then randomly selected 10,000 SNPs out of LD-pruned SNP sets. We also re-ordered individuals according to their pairwise kinship level. This subset is available in `data/X_amr.rda`. This data has `r nrow(X_amr)` individuals and `r ncol(X_amr)` loci. The associated fam file can be found in `data/fam_amr.rda`. These data can be reproduced by scripts `data-raw/{amr.bash,amr.R}`.
236236

237-
We adopt the `popkin` package to obtain the Ochoa-Storey (OS) estimate of coancestry among individuals. The following chunk of the code estimates the individual-level coancestry according to the Ochoa-Storey (OS) method by `popkin` package. It should noted that the `popkin` function returns the kinship coefficients instead of the coancestry coefficients. Therefore, we use the `inbr_diag` function in the `popkin` package to map kinship coefficients $\phi_{jk}$'s to coancestry coefficients $\theta_{jk}$'s:
237+
We adopt the `popkin` package to obtain the Ochoa-Storey (OS) estimate of coancestry among individuals. The following chunk of the code estimates the individual-level coancestry $\hat{\boldsymbol{\Theta}}^{\text{OS}}$ according to the Ochoa-Storey (OS) method by `popkin` package. It should noted that the `popkin` function returns the kinship coefficients instead of the coancestry coefficients. Therefore, we use the `inbr_diag` function in the `popkin` package to map kinship coefficients $\phi_{jk}$'s to coancestry coefficients $\theta_{jk}$'s:
238238

239239
\[
240240
\theta_{jk} =
@@ -308,7 +308,7 @@ legend_color_categories(colors = colors_subpops, categories = subpop_order, labe
308308

309309
## Estimating admixture proportions and coancestry among antecedent populations
310310

311-
The following chunk of the code estimates the admixture proportions $\bQ$ from genotypes. We first estimate the individual specific allele frequencies $\boldsymbol{\Pi}$ using the `est_p_indiv` function in the `superadmixture` package. We then estimate $\bQ$ by decomposing $\boldsymbol{\Pi}$ with `factor_p_indiv` function in the `superadmixture` package.
311+
The following chunk of the code estimates the admixture proportions $\bQ$ from genotypes. We first estimate the individual specific allele frequencies $\boldsymbol{\Pi}$ using the `est_p_indiv` function in the `superadmixture` package. We then estimate $\bQ$ by decomposing $\boldsymbol{\Pi}$ with `factor_p_indiv` function in the `superadmixture` package.
312312

313313
```{r estimate_admix_props_amr, eval=!fast_run, message=FALSE, warning=FALSE}
314314
library(superadmixture)
@@ -323,7 +323,7 @@ obj <- factor_p_indiv(p_indiv, k_antepops = 3, rowspace = rowspace, verbose = FA
323323
Q_hat <- obj$Q_hat
324324
```
325325

326-
After obtaining individual-level coancestry `coanc_indiv` and admixture proportions `Q_hat`, we can use the function `est_coanc` to estimate population coancestry under the super admixture model and under the standard admixture model.
326+
After obtaining individual-level coancestry `coanc_indiv` and admixture proportions `Q_hat`, we can use the function `est_coanc` to estimate population coancestry $\boldsymbol{\Lambda}$ under the super admixture model and under the standard admixture model. In our manuscript, `coanc_pops_sup` is denoted as $\hat{\boldsymbol{\Lambda}}^{\text{sup}}$ and `coanc_pops_std` is denoted as $\hat{\boldsymbol{\Lambda}}^{\text{std}}$.
327327

328328
```{r estimate_coanc_pops_amr, eval=!fast_run, message=FALSE, warning=FALSE}
329329
# estimate population coancestry under the super admixture model
@@ -381,7 +381,7 @@ heatmap_coanc_antepops(coanc_pops_sup, tl.offset = 1)
381381

382382
## Calculating the individual-level coancestry under the super admixture and standard admixture
383383

384-
We then obtain the corresponding individual-coancestry under the super admixture model and under the standard admixture model.
384+
We then obtain the corresponding individual-coancestry under the super admixture model and under the standard admixture model. In our manuscript, `coanc_sup` is denoted as $\hat{\boldsymbol{\Theta}}^{\text{sup}}$ and `coanc_std` is denoted as $\hat{\boldsymbol{\Theta}}^{\text{std}}$.
385385

386386
```{r estimate_coanc_supadmix_stdadmix_amr, eval=!fast_run, message=FALSE, warning=FALSE}
387387
coanc_sup <- t(Q_hat) %*% coanc_pops_sup %*% Q_hat
@@ -489,7 +489,7 @@ kinship <- ifelse(kinship< 0, 0, kinship)
489489
coanc_indiv <- ifelse(coanc_indiv < 0, 0, coanc_indiv)
490490
```
491491

492-
We can visualize the individual-level coancestry of the simulated data using `plot_popkin` function in the `popkin` function. We use the following helper function `plot_colors_subpops` to label the sub-populations.
492+
We can visualize the individual-level coancestry of the simulated data using `plot_popkin` function in the `popkin` package. We use the following helper function `plot_colors_subpops` to label the sub-populations.
493493

494494
```{r}
495495
plot_colors_subpops <- function(pops, srt = 0, cex = 0.6, y = FALSE) {
@@ -538,7 +538,7 @@ obj <- factor_p_indiv(p_indiv, k_antepops = 7, rowspace = rowspace, verbose = FA
538538
Q_hat <- obj$Q_hat
539539
```
540540

541-
After obtaining individual-level coancestry `coanc_indiv` and admixture proportions `Q_hat`, we can use the function `est_coanc` to estimate population coancestry under the super admixture model and under the standard admixture model. The output `coanc_pops_sup` is the coancestry of antecedent populations $\boldsymbol{\Lambda}$ in our manuscript.
541+
After obtaining individual-level coancestry `coanc_indiv` and admixture proportions `Q_hat`, we can use the function `est_coanc` to estimate population coancestry $\boldsymbol{\Lambda}$ under the super admixture model and under the standard admixture model. In our manuscript, `coanc_pops_sup` is denoted as $\hat{\boldsymbol{\Lambda}}^{\text{sup}}$ and `coanc_pops_std` is denoted as $\hat{\boldsymbol{\Lambda}}^{\text{std}}$.
542542

543543
```{r estimate_coanc_antepops_hgdp, eval=!fast_run, message=FALSE, warning=FALSE}
544544
# estimate population coancestry under the super admixture model
@@ -606,7 +606,7 @@ heatmap_coanc_antepops(coanc_pops_sup, tl.offset = 1)
606606

607607
## Calculating individual-level coancestry under the super admixture and standard admixture
608608

609-
We then obtain the corresponding individual-coancestry under the super admixture model and under the standard admixture model.
609+
We then obtain the corresponding individual-coancestry under the super admixture model and under the standard admixture model. In our manuscript, `coanc_sup` is denoted as $\hat{\boldsymbol{\Theta}}^{\text{sup}}$ and `coanc_std` is denoted as $\hat{\boldsymbol{\Theta}}^{\text{std}}$.
610610

611611
```{r estimate_coanc_supadmix_stdadmix_hgdp, eval=!fast_run, message=FALSE, warning=FALSE}
612612
coanc_sup <- t(Q_hat) %*% coanc_pops_sup %*% Q_hat

0 commit comments

Comments
 (0)