ref_genome | R Documentation |
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)
genome_ptr
An externalptr
object pointing to a C++ object that stores
the information about the reference genome.
print()
Print a ref_genome
object.
ref_genome$print()
ptr()
View pointer to underlying C++ object (this is not useful to end users).
ref_genome$ptr()
An externalptr
object.
n_chroms()
View number of chromosomes.
ref_genome$n_chroms()
Integer number of chromosomes.
sizes()
View chromosome sizes.
ref_genome$sizes()
Integer vector of chromosome sizes.
chrom_names()
View chromosome names.
ref_genome$chrom_names()
Character vector of chromosome names.
chrom()
View one reference chromosome.
ref_genome$chrom(chrom_ind)
chrom_ind
Index for the focal chromosome.
A single string representing the chosen chromosome's DNA sequence.
gc_prop()
View GC proportion for part of one reference chromosome.
ref_genome$gc_prop(chrom_ind, start, end)
chrom_ind
Index for the focal chromosome.
start
Point on the chromosome at which to start the calculation (inclusive).
end
Point on the chromosome at which to end the calculation (inclusive).
A double in the range [0,1]
representing the proportion of DNA
sequence that is either G
or C
.
nt_prop()
View nucleotide content for part of one reference chromosome
ref_genome$nt_prop(nt, chrom_ind, start, end)
nt
Which nucleotide to calculate the proportion that the DNA
sequence is made of. Must be one of T
, C
, A
, G
, or N
.
chrom_ind
Index for the focal chromosome.
start
Point on the chromosome at which to start the calculation (inclusive).
end
Point on the chromosome at which to end the calculation (inclusive).
A double in the range [0,1]
representing the proportion of DNA
sequence that is nt
.
set_names()
Change chromosome names.
ref_genome$set_names(new_names)
new_names
Vector of new names to use. This must be the same length as the number of current names.
This R6
object, invisibly.
ref <- create_genome(4, 10) ref$set_names(c("a", "b", "c", "d"))
clean_names()
Clean chromosome names, converting " :;=%,\\|/\"\'"
to "_"
.
ref_genome$clean_names()
This R6
object, invisibly.
ref <- create_genome(4, 10) ref$set_names(c("a:", "b|", "c;", "d'")) ref$clean_names()
add_chroms()
Add one or more chromosomes.
ref_genome$add_chroms(new_chroms, new_names = NULL)
new_chroms
Character vector of DNA strings representing new chromosomes.
new_names
Optional 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
.
This R6
object, invisibly.
ref <- create_genome(4, 10) ref$add_chroms("TCAGTCAG")
rm_chroms()
Remove one or more chromosomes by name
ref_genome$rm_chroms(chrom_names)
chrom_names
Vector of the name(s) of the chromosome(s) to remove.
This R6
object, invisibly.
ref <- create_genome(4, 10) ref$set_names(c("a", "b", "c", "d")) ref$rm_chroms("b")
merge_chroms()
Merge chromosomes into one.
ref_genome$merge_chroms(chrom_names)
chrom_names
Vector 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.
This R6
object, invisibly.
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.
ref_genome$filter_chroms(threshold, method)
threshold
Number 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.
method
String indicating which filter method to use: chromosome size
(method = "size"
) or proportion of total bases (method = "prop"
).
This R6
object, invisibly.
ref <- create_genome(4, 100, 50) ref$filter_chroms(90, "size") ref$filter_chroms(0.4, "prop")
replace_Ns()
Replace N
s in the reference genome.
ref_genome$replace_Ns(pi_tcag, n_threads = 1, show_progress = FALSE)
pi_tcag
Numeric vector (length 4) indicating the sampling weights
for T
, C
, A
, and G
, respectively, for generating new nucleotides
with which to replace the N
s.
n_threads
Optional integer specifying the threads to use.
Ignored if the package wasn't compiled with OpenMP. Defaults to 1
.
show_progress
Optional logical indicating whether to show a
progress bar. Defaults to FALSE
.
This R6
object, invisibly.
read_fasta
create_genome
## ------------------------------------------------
## 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.