---
title: "IITA EA 2020 Imputation"
site: workflowr::wflow_site
author: "Marnin Wolfe"
output:
  workflowr::wflow_html:
    toc: false
editor_options:
  chunk_output_type: console
---

This repository and website documents all analyses, summary, tables and figures associated with IITA-EA imputation and related procedures.

# Imputation of DCas20-5261

From Morag: "there are five main parents in the CET trial and nine parents in PYT trial. The parents in CET are included in the 9 PYT parents. Nine main parents in PYT. Also in CET trial."

-   MH05/0091 clone
-   MM06/0130 clone
-   MH05/0277 clone
-   MH05/0309 clone
-   MM06/0090 clone
-   MM06/0123 clone
-   MM06/0128 clone
-   MM09/0200 clone
-   TME-14 clone

So: from conversation in email, impute with E. Africa Imputation Reference Panel dataset, which can be found on the [Cassavabase FTP server here](ftp://ftp.cassavabase.org/marnin_datasets/nextgenImputation2019/ImputationEastAfrica_StageII_90919/) with names e.g. `chr*_ImputationReferencePanel_StageVI_91119.vcf.gz` with [code/documentation here](https://wolfemd.github.io/NaCRRI_2020GS/).

Original report `DCas20_5261` was not in format used for NextGen GS, i.e. a format that includes "counts" and ~VCF files. We were able to obtain a the right formats through Andrzej: `OrderAppendix_1_DCas20-5261`. 

**Steps**:

-   [Convert DCas20-5261](convertDCas20_5261_ToVCF.html)
-   [Impute DCas20-5261](ImputeDCas20_5261.html): with East Africa reference panel

**Files**:

-   **RefPanel VCF filename:** `chr*_ImputationReferencePanel_StageVI_91119.vcf.gz`
-   **Imputed filename:** `chr*_DCas20_5261_EA_REFimputed.vcf.gz`
-   **Post-impute filtered filename:** `chr*_DCas20_5261_EA_REFimputedAndFiltered.vcf.gz`
-   **Genome-wide dosage matrix format for use in R:**
    -   Imputation Reference Panel: `DosageMatrix_ImputationReferencePanel_StageVI_91119.rds`
    -   DCas20\_5261 with standard post-impute filter: `DosageMatrix_DCas20_5261_EA_REFimputedAndFiltered.rds`

**HOW TO COMBINE DOSAGE MATRICES:** Users will want to combine the genotypes in the imputation reference panel files, with the genotypes in the imputed DArT file. They can have slightly different sets of markers along the columns. Here is a basic example how to combine:

```{r, eval=F}
snps_refpanel<-readRDS("DosageMatrix_ImputationReferencePanel_StageVI_91119.rds")
snps_dcas20_5261<-readRDS("DosageMatrix_DCas20_5261_EA_REFimputedAndFiltered.rds")

snps2keep<-colnames(snps_refpanel)[,colnames(snps_refpanel) %in% colnames(snps_dcas20_5261)]
snps<-bind_rows(snps_refpanel[,snps2keep],
                snps_dcas20_5261[,snps2keep])
```


# Data availability and reproducibility

The R package **workflowr** was used to document this study reproducibly.

Much of the supporting data *and* output from the analyses documented here are too large for GitHub.

The repository will be mirrored, here: <ftp://ftp.cassavabase.org/marnin_datasets/IITA_EA_2020/> with all data.

# Directory structure of this repository

**NOTICE:** `data/` and `output/` are empty on GitHub. Please see <ftp://ftp.cassavabase.org/marnin_datasets/IITA_EA_2020/> for access.

1.  `data/`: raw data (e.g. unimputed SNP data)
2.  `output/`: outputs (e.g. imputed SNP data)
3.  `analysis/`: most code and workflow documented in **.Rmd** files
4.  `docs/`: compiled **.html**, "knitted" from **.Rmd**

Supporting functions `code/`

The analyses in the **html** / **Rmd** files referenced above often source R scripts in the `code/` sub-folder.
