Interactive wrapper for a pointer to a C++ object that stores reference genome information.
This class should NEVER be created using ref_genome$new.
Only use read_fasta or create_genome.
Because this class wraps a pointer to a C++ object, there are no fields to
manipulate directly.
All manipulations are done through this class's methods.
new()Do NOT use this; only use read_fasta or create_genome to make a
new ref_genome.
ref_genome$new(genome_ptr)gc_prop()View GC proportion for part of one reference chromosome.
nt_prop()View nucleotide content for part of one reference chromosome
ntWhich nucleotide to calculate the proportion that the DNA
sequence is made of. Must be one of T, C, A, G, or N.
chrom_indIndex for the focal chromosome.
startPoint on the chromosome at which to start the calculation (inclusive).
endPoint on the chromosome at which to end the calculation (inclusive).
set_names()Change chromosome names.
new_namesVector of new names to use. This must be the same length as the number of current names.
ref <- create_genome(4, 10)
ref$set_names(c("a", "b", "c", "d"))
clean_names()Clean chromosome names, converting " :;=%,\\|/\"\'" to "_".
ref <- create_genome(4, 10)
ref$set_names(c("a:", "b|", "c;", "d'"))
ref$clean_names()
add_chroms()Add one or more chromosomes.
new_chromsCharacter vector of DNA strings representing new chromosomes.
new_namesOptional character vector of names for the new chromosomes.
It should be the same length as new_chroms.
If NULL, new names will be automatically generated. Defaults to NULL.
ref <- create_genome(4, 10)
ref$add_chroms("TCAGTCAG")rm_chroms()Remove one or more chromosomes by name
ref <- create_genome(4, 10)
ref$set_names(c("a", "b", "c", "d"))
ref$rm_chroms("b")
merge_chroms()Merge chromosomes into one.
chrom_namesVector of the names of the chromosomes to merge into one.
Duplicates are not allowed, and chromosomes are merged in the order
they're provided.
If this is NULL, then all chromosomes are merged after first
shuffling their order.
ref <- create_genome(4, 10)
ref$merge_chroms(ref$chrom_names()[1:2])
ref$merge_chroms(NULL)
filter_chroms()Filter chromosomes by size or for a proportion of total bases.
thresholdNumber used as a threshold. If method == "size",
then this is the minimum length of a chromosome that will remain after
filtering.
If method == "prop", chromosomes are first size-sorted, then
the largest N chromosomes are retained that allow at least
threshold * sum(<all chromosome sizes>) base pairs remaining after
filtering.
methodString indicating which filter method to use: chromosome size
(method = "size") or proportion of total bases (method = "prop").
ref <- create_genome(4, 100, 50)
ref$filter_chroms(90, "size")
ref$filter_chroms(0.4, "prop")
replace_Ns()Replace Ns in the reference genome.
pi_tcagNumeric vector (length 4) indicating the sampling weights
for T, C, A, and G, respectively, for generating new nucleotides
with which to replace the Ns.
n_threadsOptional integer specifying the threads to use.
Ignored if the package wasn't compiled with OpenMP. Defaults to 1.
show_progressOptional logical indicating whether to show a
progress bar. Defaults to FALSE.
## ------------------------------------------------
## Method `ref_genome$set_names`
## ------------------------------------------------
ref <- create_genome(4, 10)
ref$set_names(c("a", "b", "c", "d"))
## ------------------------------------------------
## Method `ref_genome$clean_names`
## ------------------------------------------------
ref <- create_genome(4, 10)
ref$set_names(c("a:", "b|", "c;", "d'"))
ref$clean_names()
## ------------------------------------------------
## Method `ref_genome$add_chroms`
## ------------------------------------------------
ref <- create_genome(4, 10)
ref$add_chroms("TCAGTCAG")
## ------------------------------------------------
## Method `ref_genome$rm_chroms`
## ------------------------------------------------
ref <- create_genome(4, 10)
ref$set_names(c("a", "b", "c", "d"))
ref$rm_chroms("b")
## ------------------------------------------------
## Method `ref_genome$merge_chroms`
## ------------------------------------------------
ref <- create_genome(4, 10)
ref$merge_chroms(ref$chrom_names()[1:2])
ref$merge_chroms(NULL)
## ------------------------------------------------
## Method `ref_genome$filter_chroms`
## ------------------------------------------------
ref <- create_genome(4, 100, 50)
ref$filter_chroms(90, "size")
ref$filter_chroms(0.4, "prop")