Skip to content

Commit

Permalink
verbose message
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Dec 11, 2023
1 parent aac662c commit 529ac78
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: vcfppR
Title: Rapid Manipulation of The VCF/BCF Format in R
Title: Rapid Manipulation of the Variant Call Format (VCF) in R
Version: 0.3.5
Authors@R:
person("Zilong", "Li", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-5859-2078"))
Description: The https://github.com/Zilong-Li/vcfpp is an easy-to-use C++ API of htslib, offering the full functionalities as the htslib to manipulate the VCF/BCF file. Thus, this package is built upon the vcfpp.h to provide rapid genomic variant analyses on the VCF/BCF file in R.
Description: The <https://github.com/Zilong-Li/vcfpp> is an easy-to-use C++ API of htslib, offering the full functionalities as the htslib to manipulate the VCF/BCF file. Thus, this package is built upon the vcfpp.h to provide rapid variant processing with the variant call format in R.
Encoding: UTF-8
Depends: R (>= 3.6.0)
Roxygen: list(markdown = TRUE)
Expand Down
2 changes: 2 additions & 0 deletions R/vcf-tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ vcftable <- function(vcffile, region = "", samples = "-", vartype = "all", forma
res <- NULL
if(format == "GT") {
res <- tableGT(vcffile, region, samples, "GT", ids, qual, pass, info, snps, indels, multiallelics, multisnps)
if(length(res$gt)==0) return(res)
res[[10]] <- do.call("rbind", res[[10]])
n <- ncol(res$gt)
ploidy <- n / length(res$samples)
Expand All @@ -116,3 +117,4 @@ vcftable <- function(vcffile, region = "", samples = "-", vartype = "all", forma
}
return(res)
}

4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ In addtion to two classes for R-bindings of vcfpp.h, there are some useful funct

## Read VCF as tabular data in R

This example shows how to read only SNP variants with FILTER="PASS" and GT format in the VCF/BCF into R tables:
This example shows how to read only SNP variants with genotypes in the VCF/BCF into R tables:
```r
library(vcfppR)
vcffile <- "https://ftp.1000genomes.ebi.ac.uk/vol1/ftp/data_collections/1000G_2504_high_coverage/working/20220422_3202_phased_SNV_INDEL_SV/1kGP_high_coverage_Illumina.chr21.filtered.SNV_INDEL_SV_phased_panel.vcf.gz"
res <- vcftable(vcffile, "chr21:1-5100000", vartype = "snps", pass = TRUE)
res <- vcftable(vcffile, "chr21:1-5100000", vartype = "snps")
str(res)
```

Expand Down
4 changes: 2 additions & 2 deletions man/vcfppR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/vcfpp-read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ List tableFormat(std::string vcffile, std::string region, std::string samples, s
filter.push_back(var.FILTER());
if (INFO) info.push_back(var.INFO());
}
Rcout << "there is no " << format << " in the FORMAT\n";
return List::create(Named("samples") = vcf.header.getSamples(), Named("chr") = chr,
Named("pos") = pos, Named("id") = id, Named("ref") = ref,
Named("alt") = alt, Named("qual") = qual, Named("filter") = filter,
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-vcfpp-table.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ library(testthat)
vcffile <- system.file("extdata", "raw.gt.vcf.gz", package="vcfppR")

test_that("extract GT for all SNPs", {
res <- vcftable(vcffile, vartype = "snps")
res <- vcftable(vcffile, vartype = "snps", format = "AA")
## if all are SNPs and ALT!="."
expect_identical(sum(res$alt!=""), length(res$alt))
})
Expand All @@ -16,4 +16,3 @@ test_that("extract GT for variant with ID=chr21:5030516:G:A", {
expect_equal(res$alt, "A")
})


0 comments on commit 529ac78

Please sign in to comment.