GithubHelp home page GithubHelp logo

mrc-ide / mipanalyzer Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 1.0 7.78 MB

Filtering and analysis of MIP data

Home Page: https://mrc-ide.github.io/MIPanalyzer/

License: MIT License

R 83.90% C++ 15.98% C 0.12%

mipanalyzer's Introduction

develop checks master checks

MIPanalyzer

MIPanalyzer is a tool for analyzing MIP (molecular inversion probe) data. It performs the following functions:

  • Reading in raw data, usually in the form of a vcf file produced by MIPwrangler
  • Filtering samples and loci based on coverage, missingness, and other metrics
  • Performing simple population genetic analyses, such as PCA and basic pairwise distance metrics

All documentation, including installation instructions and tutorials, are on the MIPanalyzer website.

Version History

The current release version of the software is v1.1.0, released 12 Dec 2023.

Contributors

mipanalyzer's People

Contributors

bobverity avatar ojwatson avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

Forkers

ojwatson

mipanalyzer's Issues

Extension for MAPs

Right now we have GC distance calculations but otherwise few spatial functions/capabilities. Worth extending?

Do we want spatial IBD networks?

sf and shape files are not small tasks... but is useful for comm?

array limited to 3 ALT

Hey Bob,

For the array under mipanalyzer_data your dimensions are dim(3, n, L) where 3 is ALT alleles, n is samples, L is loci. This absolutely makes sense for SNP data (where ALT is bounded by the 4 nucleotide bases) but will fail for INDEL data where the theoretical upper limit of ALT is n-1 (i.e. ever sample has its own unique INDEL). Granted, these latter points get a bit muddled, as we can see in example 5.1.2 here.
Regardless, I thought it was important to perserve the fact that ALT length changes depending on the loci in our data-structure. If you disagree and want to use an array of max(ALT) x n x L we can do that too?
Also -- sorry if I missing something -- but it was unclear to me why coverage was an array? I just returned a simple matrix ?

vcf_example_altref_indels

This is my vcf2mip_data function PR/proposa:

vcf2mipanalyzer_data <- function(file = NULL, vcfR = NULL, verbose = TRUE){
  #.....................
  # Read and check input
  #.....................
  if(is.null(file) & is.null(vcfR)){
    stop("You must specify an input: either a raw vcf file path or a vcfR object")
  } else if(!is.null(file) & !is.null(vcfR)){
    stop("You must specify one input: either a raw vcf file path or a vcfR object")

  } else if(!is.null(vcfR)){ # user specified a vcfR object
    if(!inherits(vcfR, "vcfR")){
      stop("vcfR object must be of class vcfR")
    }
    vcf <- vcfR

  } else if(!is.null(file)){ # user specified a file
    if(!file.exists(file)){
      stop("The vcf does not appear to exist at that file path")
    }
    vcf <- vcfR::read.vcfR(file=file, verbose=verbose) # read vcf
  }

  #..........................
  # find features and convert
  #..........................
  countmat <- vcfR::extract.gt(vcf, element="AD")
  counts <- sapply(1:nrow(countmat), function(x){ # R version of a for loop
    ret <- t(stringr::str_split(countmat[x,], ",", simplify = T))
    ret <- apply(ret, 2, as.numeric) # need to coerce to numeric here b/c of way vcfR extracts AD (can't set as.numeric T and retain all info) and to perserve df structure
    return(ret)
  }) # note, doing this way instead of an array to perserve the fact that the ALT count varies by loci as you could see by the command below
     # d <- sapply(vcf@fix[,5], function(x){ return(length(unlist(stringr::str_split(x, ","))))}) # ALT count per loci

  coverage <- vcfR::extract.gt(vcf, element="DP", as.numeric = T)

  # create data
  ret <- list(coverage = coverage,
              counts = counts,
              samples = colnames(vcf@gt)[2:ncol(vcf@gt)],
              loci = vcf@fix # keep all the info here not just loci pos?
              )

  # return in mipanalyzer_data class
  class(ret) <- "mipanalyzer_data"
  return(ret)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.