plotDynamics {doblin} | R Documentation |
Plot barcode dynamics
Description
This function plots the dynamics of barcode frequencies over time, using either linear-scale area plots, logarithmic-scale line plots, or both. Only the most frequent barcodes are colored.
Usage
plotDynamics(
reshaped_df,
colored_topFreq_df,
min_freq_threshold,
plot_model,
output_directory,
input_name
)
Arguments
reshaped_df |
A dataframe produced by |
colored_topFreq_df |
A dataframe with top barcodes and their assigned color hex codes and max frequencies. |
min_freq_threshold |
A numeric threshold; barcodes with max frequency below this are colored gray. |
plot_model |
One of |
output_directory |
A string specifying the directory where plots will be saved. |
input_name |
A string used as the base name for output files (e.g., "replicate1"). |
Value
No return value. Depending on the plot_model
parameter:
Saves a linear-scale area plot (
_area.jpg
) showing the dynamics of barcode frequencies over time.Saves a logarithmic-scale line plot (
_line.eps
) highlighting prominent barcodes across time.
Examples
# Load demo barcode count data
demo_file <- system.file("extdata", "demo_input.csv", package = "doblin")
input_dataframe <- readr::read_csv(demo_file, show_col_types = FALSE)
# Reshape and extract top lineages
reshaped_df <- reshapeData(input_dataframe)
top_barcodes <- fetchTop(reshaped_df, N_LINEAGES = 10)
# Load color list and assign hex codes
color_file <- system.file("extdata", "top_colors2.csv", package = "doblin")
color_df <- readr::read_csv(color_file, show_col_types = FALSE)
color_df <- color_df[1:nrow(top_barcodes), ]
colored_top <- cbind(top_barcodes, color_df)
# Plot dynamics
plotDynamics(
reshaped_df = reshaped_df,
colored_topFreq_df = colored_top,
min_freq_threshold = 0.001,
plot_model = "both",
output_directory = tempdir(),
input_name = "demo"
)