GithubHelp home page GithubHelp logo

yangjl / pseudoref Goto Github PK

View Code? Open in Web Editor NEW
13.0 5.0 5.0 277 KB

Make Pseudo-Reference Genome from VCF/BCF

Home Page: http://yangjl.com/pseudoRef/

R 0.80% HTML 99.20%
bioinformatics pseudo-reference-genome bcf devtools

pseudoref's Introduction

pseudoRef

It is an R package to make a pseudo reference genome subsituted with the SNP variants of given samples.

Installation (< 10 mins)

Install devtools first, and then use devtools to install pseudoRef from github.

devtools::install_github("yangjl/pseudoRef")

It requires two other papckages:

library("data.table")
library("Biostrings")

Usage

You can find help documentation by simply typing ?pseudoRef, which is the major function have been implemented in this package.

Usage:

     pseudoRef(fa, snpdt, sidx = 5:ncol(snpdt), arules = NULL, outdir)

Arguments:

      fa: Path for the reference fasta file. [string or
          DNAStringSet/DNAString object]

   snpdt: A data.table object with heterozygote SNPs coded with IUPAC
          ambiguity codes. [data.table, 4 required columns: chr, pos,
          ref, alt, (sample1, ..., sampleN)]

    sidx: A vector to indicate the sample columns. [vector,
          default=5:ncol(snpdt)].

  arules: Additional nucleotide substitution rules defined by users.
          [data.frame, 2 required columns: from, to, default=NULL] For
          example, arules <- data.frame(from=c("M", "Y", "R", "K"),
          to=c("C", "C", "G", "T")).

  outdir: Output directory. Sample specific sub-folders will be
          created. [string]

Note

Before running the package, we should use BCFtools to convert VCF/BCF file into IUPAC coded tab seperated file:

# bcftools view JRI20_filtered_snps_annot.bcf.gz -m2 -M2 -v snps -Oz -o JRI20_bi_snps_annot.vcf.gz
# bcftools query -f '%CHROM\t%POS\t%REF\t%ALT[\t%IUPACGT]\n' JRI20_bi_snps_annot.vcf.gz > JRI20_bi_snps_annot.txt
# bcftools query -f 'chr\tpos\tref\talt[\t%SAMPLE]\n' JRI20_bi_snps_annot.vcf.gz > JRI20_bi_snps_annot.header

License

This package is free and open source software, licensed under GPL.

pseudoref's People

Contributors

yangjl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pseudoref's Issues

object 'SAMPLE' not found

I have been trying to use it, but I keep running into errors, and I would really appreciate your help.

The error I keep running into is this:

pseudoRef(fa=fa, snpdt= snpdt, sidx=sidx, arules=NULL, outdir="/work/alj25/MED84_pseudoref/")
Error in [.data.frame(x, i) : object 'SAMPLE' not found
I converted my fasta reference to a DNAstring object (using readDNAStringSet), my snpdt is a data.table from my bcftools output, as you describe. I think the problem may lie there, because 1. I had to add names to the columns after importing (I never used the .header file you specified. How do I incorporate that?) 2. I only have 1 sample in the file, not multiple, so I don't think I'm actually able to provide a vector (sidx=5; and I have tried 5:5, 5 as an int and num).

Your script looks like it replaces the sample column name with "SAMPLE" in a loop, so I'm not sure why this isn't working, but please let me know if you do. I have also tried naming that column "SAMPLE" from the start, but I keep getting this error.

BCFtools filteration criterion (biallelic sites)

Hi,

Thanks for the 'pseudoRef' commitment.

I noticed that you kept only biallelic sites by using '-m2 -M2' parameters in bcftools.
bcftools view JRI20_filtered_snps_annot.bcf.gz -m2 -M2 -v snps -Oz -o JRI20_bi_snps_annot.vcf.gz

There are other multiallelic sites in a large population, why do you discard those sites?

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.