get_mutation_df: 'get_mutation_df' Converts sizes to the frequency of the...

Description Usage Arguments Examples

View source: R/EvoFreq_funcs.R

Description

get_mutation_df Converts sizes to the frequency of the mutations in the population

Usage

1
get_mutation_df(clone_size_df, clones, parents)

Arguments

clone_size_df

Dataframe in a wide format, where each row corrsponds to a single clone, and the columns are the sizes of that clone at each timepoint

clones

Array containing the clone ids. The index of each clone must correspond to the same index of the row in size_df that contains the sizes of that clone over time

parents

Array containing the ids of the parent of each clone in the clones array.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data("example.easy.wide")
### Split dataframe into clone info and size info using fact timepoint column names can be converted to numeric values
time_col_idx <- suppressWarnings(which(! is.na(as.numeric(colnames(example.easy.wide)))))
attribute_col_idx <-suppressWarnings(which(is.na(as.numeric(colnames(example.easy.wide)))))
attribute_df <- example.easy.wide[, attribute_col_idx]
size_df <- example.easy.wide[, time_col_idx]
parents <- example.easy.wide$parents
clones <- example.easy.wide$clones
### Size data can be converted to mutation counts for additional analyses, like calculating mutation frequencies
mutation_count_df <- get_mutation_df(size_df, clones, parents)
total_chromosomes <- 2*colSums(size_df) ### Calculation assumes that mutations are on a single chromosome
allele_frequency_df <- sweep(mutation_count_df,2,total_chromosomes,"/")

MathOnco/EvoFreq documentation built on Jan. 26, 2022, 7:31 p.m.