View source: R/hpo_to_matrix.R
hpo_to_matrix | R Documentation |
Convert gene-phenotype associations from the Human Phenotype Ontology (HPO)
into a gene x phenotype matrix. The returned matrix is sparse and binary,
such that 1 indicates a the gene is associated with a given phenotype
according to the HPO annotation, and 0 indicates it is not.
By default, full phenotype names are used as the column names
(e.g. "Abnormality of body height"),
however you can instead set them to the HPO IDs
by changing the formula
argument to:
formula = "gene_symbol ~ hpo_id"
.
Phenotypes that are not present in the phenotype_to_genes
annotations
are omitted from the final matrix.
hpo_to_matrix(
terms = NULL,
phenotype_to_genes = load_phenotype_to_genes(),
formula = "gene_symbol ~ hpo_id",
fun.aggregate = mean,
value.var = "evidence_score_sum",
fill = 0,
run_cor = FALSE,
as_matrix = TRUE,
as_sparse = TRUE,
method = "pearson",
verbose = TRUE
)
terms |
A subset of HPO IDs to include.
Set to |
phenotype_to_genes |
Output of load_phenotype_to_genes mapping phenotypes to gene annotations. |
formula |
A formula of the form LHS ~ RHS to cast, see Details. |
fun.aggregate |
Should the data be aggregated before casting? If the formula doesn't identify a single observation for each cell, then aggregation defaults to To use multiple aggregation functions, pass a |
value.var |
Name of the column whose values will be filled to cast. Function Cast multiple |
fill |
Value with which to fill missing cells. If |
run_cor |
Return a matrix of pairwise correlations. |
as_matrix |
Return the results as a matrix ( |
as_sparse |
Convert the data to a sparse matrix.
Only used when |
method |
Method to construct plot with. |
verbose |
Print messages. |
A gene x phenotype matrix,
or a phenotype x phenotype matrix if run_cor=TRUE
.
phenos <- example_phenos()
X <- hpo_to_matrix(terms = phenos$hpo_id)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.