create_phylotree: Create a 'Phylotree' object

View source: R/phylotree_class.R

create_phylotreeR Documentation

Create a Phylotree object

Description

This is the general constructor of the Phylotree S4 class.

Usage

create_phylotree(B, clones, genes, parents, tree, labels = NA)

Arguments

B

A square matrix that represents the phylogenetic tree.

clones

A numeric vector representing the clones in the phylogenetic tree.

genes

A numeric vector representing the genes in the phylogenetic tree.

parents

A numeric vector representing the parents of the clones in the phylogenetic tree.

tree

A data.tree object containing the tree structure of the phylogenetic tree.

labels

An optional vector containing the tags of the genes in the phylogenetic tree. NA by default.

Value

A Phylotree class object.

Examples

# Create a B matrix instance
# composed by 10 subpopulations of
# clones
B <- create_instance(
       n = 10, 
       m = 4, 
       k = 1, 
       selection = "neutral")$B


# Create a new 'Phylotree' object
# on the basis of the B matrix
phylotree1 <- B_to_phylotree(B = B)


# Create a new 'Phylotree' object
# with the general constructor of
# the class
phylotree2 <- create_phylotree(
                B = B, 
                clones = phylotree1@clones, 
                genes = phylotree1@genes, 
                parents = phylotree1@parents, 
                tree = phylotree1@tree)


# Generate the tags for the genes of
# the phyogenetic tree
tags <- LETTERS[1:nrow(B)]

 
# Create a new 'Phylotree' object
# with the general constructor of
# the class using tags
phylotree_tags <- create_phylotree(
                    B = B, 
                    clones = phylotree1@clones, 
                    genes = phylotree1@genes, 
                    parents = phylotree1@parents, 
                    tree = phylotree1@tree, 
                    labels = tags)

GeRnika documentation built on April 3, 2025, 7:48 p.m.