View source: R/create_gr_from_sample.R
| create_gr_from_sample | R Documentation |
Generate a GRange object from sample data frame with additional columns for a vcf file
create_gr_from_sample( sample.df, seq, chromosome, info = c(), quality = c(), filter = c(), format = c(), samples = list(), sample.names = c() )
sample.df |
A data frame with columns 'mutations' and 'truth'. See output of |
seq |
A DNAString. The sequence of a chromosome. |
chromosome |
A string of the chromosome |
info |
A vector for the info column |
quality |
A vector for the quality column |
filter |
A vector for the filter column |
format |
A vector for the format column |
samples |
A list of vectors for the sample columns |
samples.names |
A vector of strings for the sample column headers |
A GRange object with the information inserted
library(MutationalPatterns)
library(tidyverse)
library(Biostrings)
library(BSgenome.Hsapiens.UCSC.hg38)
library(GenomicRanges)
# Load in signatures
cosmic.sigs <- get_known_signatures()
cosmic.sig4 <- as.matrix(cosmic.sigs[,4])
ffpe.sig <- get_ffpe_signature()
# Create samples
sample.sig4 <- create_signature_sample_vector(cosmic.sig4, 100)
sample.ffpe <- create_signature_sample_vector(ffpe.sig, 100)
# Create classification data frame
samples <- list(sample.sig4, sample.ffpe)
signatures <- list(cosmic.sig4, ffpe.sig)
classify.df <- classify_simulated_samples(samples, signatures)
seq <- getSeq(Hsapiens, "chr1")
create_gr_from_sample(classify.df, seq, "chr1")
# Adding values to other columns
info <- sample("SOMATIC", 200, replace = TRUE)
quality <- sample(50:100, 200, replace = TRUE)
filter <- sample("PASS", 200, replace = TRUE)
format <- sample("GT:GQ", 200, replace = TRUE)
samples <- list(sample(paste("0/0:", 1:100, sep = ""), 200, replace = TRUE), sample(paste("0/0:", 1:100, sep = ""), 200, replace = TRUE))
sample.names <- c("SAMPLE1", "SAMPLE2")
create_gr_from_sample(classify.df, seq, "chr1", info, quality, filter, format, samples, sample.names)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.