Function which creates a grid of cluster trajectories. Each cluster is split into two subplots, one for the control and the other for the experiment.
Individual gene trajectories are plotted for each cluster along with a large gray line for the mean cluster trajectories.
plot_cluster_traj(
object,
ts_data,
ts_mean_data,
yaxis_name = "scaled expression",
num_col = 4,
rem_legend_axis = FALSE,
log_TP = FALSE,
title_text_size = 14
)
A timeseries object
The trajectory data for all clusters being calculated
The data is calculated/obtained from calculate_cluster_traj_data
function
The trajectory data for all clusters being calculated
The data is calculated/obtained from calculate_cluster_traj_data
function
Name given to the yaxis, by default, scaled expression
Integer stating the number of columns for the plots.
Boolean indicating if the legend and axis titles should be removed
Boolean indicating if timepoints should be log transformed
Integer indicating what the font size of the titles should be in the facets
A ggplot2 object for the cluster trajectory plot performed
TS_object<-create_example_object_for_R()
TS_object <- normalize_timeSeries_with_deseq2(time_object=TS_object)
#> converting counts to integer mode
#Perform conditional differential gene expression analysis
TS_object<-conditional_DE_wrapper(TS_object,vignette_run=TRUE)
TS_object<-temporal_DE_wrapper(TS_object,do_all_combinations=TRUE,vignette_run=TRUE)
#Extract genes for PART clustering based on defined log(2)foldChange threshold
signi_genes<-select_genes_with_l2fc(TS_object)
#Use all samples, but implement a custom order. In this case it is reversed
sample_data<-exp_sample_data(TS_object)
TS_groups<-slot(TS_object,'group_names')
samps_2<-sample_data$sample[sample_data$group==TS_groups[2]]
samps_1<-sample_data$sample[sample_data$group==TS_groups[1]]
#Create the matrix that will be used for PART clustering
TS_object<-prep_counts_for_PART(object=TS_object,target_genes=signi_genes,scale=TRUE,target_samples=c(samps_2,samps_1))
TS_object<-compute_PART(TS_object,part_recursion=10,part_min_clust=10,dist_param="euclidean", hclust_param="average",vignette_run=TRUE)
ts_data<-calculate_cluster_traj_data(TS_object,scale_feat=TRUE) #Calculate scaled gene values for genes of clusters
mean_ts_data<-calculate_mean_cluster_traj(ts_data) #Calculate the mean scaled values for each cluster
clust_traj<-plot_cluster_traj(TS_object,ts_data,mean_ts_data)