diff --git a/R/misc.R b/R/misc.R index bdfe9a4..46c9fa2 100644 --- a/R/misc.R +++ b/R/misc.R @@ -29,7 +29,7 @@ is.int_vector <- function(x) { x == as.integer(x) } -# load system file --------------------------------------------------------------- +# load system file ------------------------------------------------------------ #' @title Load system file #' #' @description Load system file @@ -40,10 +40,11 @@ is.int_vector <- function(x) { #' #' @export #' @examples -#' # TODO +#' dat <- mipmapper_file("dummy_data.csv") mipmapper_file <- function(name) { - name_full <- system.file("extdata/", name, package='mipmapper', mustWork = TRUE) + name_full <- system.file("extdata/", name, package='mipmapper', + mustWork = TRUE) ret <- fast_read(name_full) return(ret) diff --git a/README.Rmd b/README.Rmd index f527ac9..ac4c8a5 100644 --- a/README.Rmd +++ b/README.Rmd @@ -1,6 +1,5 @@ --- output: github_document -always_allow_html: yes --- ```{r, echo = FALSE} knitr::opts_chunk$set( diff --git a/README.md b/README.md index 4bffba5..6fdada4 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ - -mipmapper -========= - -[](https://travis-ci.org/mrc-ide/mipmapper) [](https://ci.appveyor.com/project/mrc-ide/mipmapper) [](https://codecov.io/github/mrc-ide/mipmapper?branch=master) [](https://mrc-ide.github.io/mipmapper/) +# mipmapper +[](https://travis-ci.org/mrc-ide/mipmapper) +[](https://ci.appveyor.com/project/mrc-ide/mipmapper) +[](https://codecov.io/github/mrc-ide/mipmapper?branch=master) +[](https://mrc-ide.github.io/mipmapper/) The R package *mipmapper* package contains a series of functions for analysing and visualising Molecular Inversion Probe (MIP) data. **This package is in early stages of development**, but will eventually include a range of methods for carrying out population genetic analyses. Full documentation can be found [here](https://mrc-ide.github.io/mipmapper/). @@ -10,19 +10,17 @@ The R package *mipmapper* package contains a series of functions for analysing a In R, ensure that you have the devtools package installed by running -``` r +```r install.packages("devtools", repos='http://cran.us.r-project.org') ``` +Then we can simply install the *mipmapper* package directly from GitHub by running -Then we can simply install the *mipmapper* package directly from GitHub by running - -``` r +```r devtools::install_github("mrc-ide/mipmapper") ``` - And we can load the package by running -``` r +```r library(mipmapper) ``` @@ -30,31 +28,29 @@ library(mipmapper) Load raw data from .csv file. You will need to change the file path to where you have stored the data. An example of this is shown below, but commented out. -``` r +```r # if loading your own data, uncomment this line and change path to your data # dat0 <- fast_read("path_to_your_data/NeutralSNPs_AheroYombo.csv") # here we will use in-built example data dat0 <- mipmapper_file("dummy_data.csv") ``` - Some miscellaneous filtering. Subset to SNPs only (i.e. no more complex mutations), group all alternative alleles together as a single "non-reference" allele, and drop irregular loci (for example non-integer barcode counts). -``` r +```r dat1 <- filter_misc(dat0, SNP_only = TRUE, group_Alt = TRUE, drop_irregular = TRUE) ``` - Next we want to filter based on coverage, throwing away any loci that are below a minimum coverage level. We can visualise how much data will be left at different thresholds using the following function: -``` r +```r plot_coverage(dat1) ``` - + Choose a threshold that strikes a balance between data quantity and quality. Once you have chosen a threshold, apply the filtering as follows: -``` r +```r my_threshold <- 6 dat3 <- filter_coverage(dat1, min_coverage = my_threshold) ``` @@ -63,42 +59,36 @@ dat3 <- filter_coverage(dat1, min_coverage = my_threshold) Before carry out PCA analysis we will convert our filtered dataset into a wide format, where each row is an unique sample, with new columns for each locus. This can be achieved as follows: -``` r +```r dat4 <- melt_mip_data(dat3) ``` - This can then be used to impute any missing values: -``` r +```r dat5 <- impute_mip_data(dat4) ``` - The imputed data set can then be analysed using principal component analysis: -``` r +```r pca <- pca_mip_data(dat5) ``` - We can view the variance explained by each compenet graphically using: -``` r +```r plot_pca_variance(pca) ``` -  And lastly we can plot the actual prinical component analysis, to see how it has clustered our data: -``` r +```r plot_pca(pca, num_components = 2, meta_var = "Country") ``` -  We can control whether we want to visualise the first 2 or 3 components, with the `num_componenets` argument: -``` r +```r plot_pca(pca, num_components = 3, meta_var = "Country") ``` -  diff --git a/TODO.md b/TODO.md index 1b75249..2933174 100644 --- a/TODO.md +++ b/TODO.md @@ -13,4 +13,5 @@ samples, countries etc. At the moment the data is nonsense, and has no structure or PCA utility, so might be nice to come up with imporvements to make faking large clustered genetic data. 5. Shiny interface for loading a dataset, sliders for filtering, and then -displayed plots. \ No newline at end of file +displayed plots. +6. Fst permutation test \ No newline at end of file diff --git a/docs/README-plot_coverage-1.png b/docs/README-plot_coverage-1.png index b420e32..a209fb8 100644 Binary files a/docs/README-plot_coverage-1.png and b/docs/README-plot_coverage-1.png differ diff --git a/docs/TODO.html b/docs/TODO.html index 09a98a9..4f694f8 100644 --- a/docs/TODO.html +++ b/docs/TODO.html @@ -99,6 +99,7 @@
In R, ensure that you have the devtools package installed by running
install.packages("devtools", repos='http://cran.us.r-project.org')Then we can simply install the mipmapper package directly from GitHub by running
-devtools::install_github("mrc-ide/mipmapper")devtools::install_github("mrc-ide/mipmapper")And we can load the package by running
library(mipmapper)Some miscellaneous filtering. Subset to SNPs only (i.e. no more complex mutations), group all alternative alleles together as a single “non-reference” allele, and drop irregular loci (for example non-integer barcode counts).
dat1 <- filter_misc(dat0, SNP_only = TRUE, group_Alt = TRUE, drop_irregular = TRUE)Next we want to filter based on coverage, throwing away any loci that are below a minimum coverage level. We can visualise how much data will be left at different thresholds using the following function:
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 5556ad5..94fb113 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,5 +1,5 @@ -pandoc: 1.17.2 -pkgdown: 1.0.0 -pkgdown_sha: ~ +pandoc: 1.19.2.1 +pkgdown: 1.0.0.9000 +pkgdown_sha: d7c658122bfbd143552cd28585f867dd344302ad articles: [] diff --git a/docs/reference/mipmapper_file.html b/docs/reference/mipmapper_file.html index 77cb2bc..bb72205 100644 --- a/docs/reference/mipmapper_file.html +++ b/docs/reference/mipmapper_file.html @@ -117,8 +117,7 @@+# TODO -
dat <- mipmapper_file("dummy_data.csv")