R/validate_associations_correlate_ctd.R
validate_associations_correlate_ctd.RdValidate phenotype-cell type associations can making comparisons within and between results from different CellTypeDatasets.
validate_associations_correlate_ctd(
results = load_example_results(),
filters = NULL,
hpo_agg_lvl = 3,
hpo = HPOExplorer::get_hpo(),
group_var = "ctd",
celltype_var = "cl_name",
q_threshold = 0.05,
downsample = NULL,
add_density = TRUE,
marginal = FALSE,
rasterize_points = TRUE,
dpi = 100,
point.args = list(alpha = 0.5),
stats_idx = c(1, 3, 4, 7),
...
)The cell type-phenotype enrichment results generated by gen_results and merged together with merge_results
A named list, where each element in the list is the name of a column in the data, and the vector within each element represents the values to include in the final data.
Aggregate the data to a specific HPO ancestor level during plotting to reduce figure size.
Human Phenotype Ontology object, loaded from get_ontology.
A character string specifying the column in results
that contains the group variable to compare across.
A character string specifying the column in results
that contains the cell type variable to compare across.
The q value threshold to subset the results by.
Downsample the data to this many points when plotting.
Add 2D density plots to the scatter plots.
Decides whether marginal distributions will be plotted on
axes using {ggside} functions. The default is TRUE. The package
{ggside} must already be installed by the user.
Whether to rasterize the points in the scatter plots.
Resolution of image after rasterization.
A list of additional aesthetic arguments to be passed to
the ggplot2::geom_point().
Indices of statistics to keep in subtitle
Additional arguments passed to plot_density_cor.
results <- load_example_results()[,.SD[seq(10000)],by="ctd"]
#### Across CTD ####
out1 <- validate_associations_correlate_ctd(results=results,
group_var="ctd")
#> Mapping cell types to cell ontology terms.
#> Adding stage information.
#> Adding logFC column.
#> Casting results.
#> 13 comparable celltypes.
#> 62 comparable phenotypes.
#> 3 comparable celltypes @FDR<0.05.
#> 4 comparable phenotypes @FDR<0.05.
#> Generating plots.
#> Force new. Removing existing ancestor columns.
#> Warning: Tried to assign NULL to column 'ancestor', but this column does not exist to remove
#> Warning: Tried to assign NULL to column 'ancestor_name', but this column does not exist to remove
#> Adding level-3 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Getting absolute ontology level for 18,082 IDs.
#> 344 ancestors found at level 3
#> Translating ontology terms to names.
#> 804 associations remain after filtering.
#> Force new. Removing existing ancestor columns.
#> Warning: Tried to assign NULL to column 'ancestor', but this column does not exist to remove
#> Warning: Tried to assign NULL to column 'ancestor_name', but this column does not exist to remove
#> Adding level-3 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Getting absolute ontology level for 18,082 IDs.
#> 344 ancestors found at level 3
#> Translating ontology terms to names.
#> 4 associations remain after filtering.
#> Gathering statistics.
#### Within CTD: across developmental stages ####
filters <- list(ctd=c("HumanCellLandscape"), stage=c("Fetus","Adult"))
out2 <- validate_associations_correlate_ctd(results=results,
filters=filters,
group_var="stage")
#> Mapping cell types to cell ontology terms.
#> Adding stage information.
#> Adding logFC column.
#> Filtered 'ctd' : 10,000 / 20,000 rows dropped.
#> Filtered 'stage' : 404 / 10,000 rows dropped.
#> Casting results.
#> 38 comparable celltypes.
#> 81 comparable phenotypes.
#> 9 comparable celltypes @FDR<0.05.
#> 14 comparable phenotypes @FDR<0.05.
#> Generating plots.
#> Force new. Removing existing ancestor columns.
#> Warning: Tried to assign NULL to column 'ancestor', but this column does not exist to remove
#> Warning: Tried to assign NULL to column 'ancestor_name', but this column does not exist to remove
#> Adding level-3 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Getting absolute ontology level for 18,082 IDs.
#> 344 ancestors found at level 3
#> Translating ontology terms to names.
#> 3,062 associations remain after filtering.
#> Force new. Removing existing ancestor columns.
#> Warning: Tried to assign NULL to column 'ancestor', but this column does not exist to remove
#> Warning: Tried to assign NULL to column 'ancestor_name', but this column does not exist to remove
#> Adding level-3 ancestor to each HPO ID.
#> Adding ancestor metadata.
#> Getting absolute ontology level for 18,082 IDs.
#> 344 ancestors found at level 3
#> Translating ontology terms to names.
#> 17 associations remain after filtering.
#> Gathering statistics.