Interactive wrapper for a pointer to a C++ object that stores information about variant haplotypes from a single reference genome.
This class should NEVER be created using haplotypes$new
.
Only use create_haplotypes
.
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.
ref_genome
objectsRegarding the ref_genome
object you use to create a haplotypes
object, you should
note the following:
This point is the most important.
Both the ref_genome
and haplotypes
objects use the same underlying
C++ object to store reference genome information.
Thus, if you make any changes to the ref_genome
object, those changes will
also show up in the haplotypes
object.
For example, if you make a haplotypes
object named V
based on an existing ref_genome
object named R
,
then you merge chromosomes in R
,
V
will now have merged chromosomes.
If you've already started adding mutations to V
,
then all the indexes used to store those mutations will be inaccurate.
So when you do anything with V
later, your R session will crash
or have errors.
The lesson here is that you shouldn't edit the reference
genome after using it to create haplotypes.
If a ref_genome
object is used to create a haplotypes
object, deleting the ref_genome
object won't cause issues with
the haplotypes
object.
However, the haplotypes
class doesn't provide methods to edit
chromosomes, so only remove the ref_genome
object when you're done
editing the reference genome.
new()
Do NOT use this; only use create_haplotypes
to make new haplotypes
.
haplotypes$new(genomes_ptr, reference_ptr)
gc_prop()
View GC proportion for part of one haplotype chromosome.
nt_prop()
View nucleotide content for part of one haplotype chromosome
nt
Which nucleotide to calculate the proportion that the DNA
sequence is made of. Must be one of T
, C
, A
, G
, or N
.
hap_ind
Index for the focal haplotype.
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).
set_names()
Change haplotype names.
dup_haps()
Duplicate one or more haplotypes by name.
add_sub()
Manually add a substitution.
add_ins()
Manually add an insertion.
hap_ind
Index for the focal haplotype.
chrom_ind
Index for the focal chromosome.
pos
Position at which to add the mutation.
nts
String representing the nucleotide(s) that will be inserted after the designated position.
This R6
object, invisibly.
`add_del(hap_ind, chrom_ind, pos, n_nts)`}{Manually add a deletion
\item{for a given haplotype (`hap_ind`), chromosome (`chrom_ind`), and position (`pos`).
delete (`n_nts`) will be deleted
The designated number of nucleotides to `pos`, unless `pos` is near the chromosome end and doesn't have
starting at `n_nts` nucleotides to remove; it simply stops at the chromosome end in
this case.}
add_del()
Manually add a deletion.
hap_ind
Index for the focal haplotype.
chrom_ind
Index for the focal chromosome.
pos
Position at which to add the mutation.
n_nts
Single integer specifying the number of nucleotides to delete.
These will be deleted starting at pos
.
If pos
is near the chromosome end and doesn't have n_nts
nucleotides
to remove, it simply removes nucleotides from pos
to the chromosome end.