variants: An R6 class representing haploid variants from a reference...

Description Usage Format Value Connections to ref_genome objects Methods See Also


This class should NEVER be created using variants$new. Only use create_variants. This class wraps a pointer to a C++ object, which is why there are no fields to manipulate directly. All manipulations are done through this class's methods.




An R6Class generator object


An object of class variants.

Connections to ref_genome objects

Regarding the ref_genome object you use to create a variants object, you should note the following:


Viewing information:


View the pointer to the variant information. This is used internally by jackalope and shouldn't be of much use to users.


View the number of chromosomes.


View the number of variants.


View vector of chromosome sizes for a given variant.


View vector of chromosome names.


View vector of variant names.

chrom(var_ind, chrom_ind)

View a chromosome sequence string based on indices for the chromosome (chrom_ind) and variant (var_ind).

gc_prop(var_ind, chrom_ind, start, end)

View the GC proportion for a range within a variant chromosome.

nt_prop(nt, var_ind, chrom_ind, start, end)

View the proportion of a range within a variant chromosome that is of nucleotide nt.

Editing information:


Set names for all variants. new_names is a character vector of what to change names to, and it must be the same length as the # variants.


Add new, named variant(s) to the object. These variants will have no mutations. If you want to add new variants with mutations, either re-run create_variants or use the dup_vars method to duplicate existing variants.

dup_vars(var_names, new_names = NULL)

Duplicate existing variant(s) based on their name(s). You can optionally specify the names of the duplicates (using new_names). Otherwise, their names are auto-generated.


Remove one or more variants based on names in the var_names vector.

add_sub(var_ind, chrom_ind, pos, nt)

Manually add a substitution for a given variant (var_ind), chromosome (chrom_ind), and position (pos). The reference nucleotide will be changed to nt, which should be a single character.

add_ins(var_ind, chrom_ind, pos, nts)

Manually add an insertion for a given variant (var_ind), chromosome (chrom_ind), and position (pos). The nucleotide(s) nts will be inserted after the designated position.

add_del(var_ind, chrom_ind, pos, n_nts)

Manually add a deletion for a given variant (var_ind), chromosome (chrom_ind), and position (pos). The designated number of nucleotides to delete (n_nts) will be deleted starting at pos, unless pos is near the chromosome end and doesn't have n_nts nucleotides to remove; it simply stops at the chromosome end in this case.

See Also


jackalope documentation built on Dec. 1, 2019, 1:17 a.m.