Title: | R Client Library for CloudOS |
---|---|
Description: | The 'CloudOS' client library for R makes it easy to interact with CloudOS in the R environment for analysis. |
Authors: | Sangram Keshari Sahu [aut, cre], Ilya Levantis [aut], Henry Stewart [aut], Lifebit Biotech Ltd. [cph] |
Maintainer: | Sangram Keshari Sahu <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.0 |
Built: | 2025-02-22 04:55:48 UTC |
Source: | https://github.com/lifebit-ai/cloudos |
Updates a cohort by applying a new query.
cb_apply_query(cohort, query, keep_query = TRUE)
cb_apply_query(cohort, query, keep_query = TRUE)
cohort |
A cohort object. (Required)
See constructor function |
query |
A phenotype query defined using the |
keep_query |
If True, combines the newly supplied query with the pre-existing query. Otherwise, pre-existing query is overwritten. (Default: TRUE) |
The updated cohort object.
## Not run: A <- phenotype(id = 13, from = "2016-01-21", to = "2017-02-13") B <- phenotype(id = 4, value = "Cancer") A_not_B <- A & !B my_cohort <- cb_load_cohort(cohort_id = "612f37a57673ed0ddeaf1333", cb_version = "v2") my_cohort <- cb_apply_query(my_cohort, query = A_not_B, keep_query = F) ## End(Not run)
## Not run: A <- phenotype(id = 13, from = "2016-01-21", to = "2017-02-13") B <- phenotype(id = 4, value = "Cancer") A_not_B <- A & !B my_cohort <- cb_load_cohort(cohort_id = "612f37a57673ed0ddeaf1333", cb_version = "v2") my_cohort <- cb_apply_query(my_cohort, query = A_not_B, keep_query = F) ## End(Not run)
Creates a new Cohort
cb_create_cohort(cohort_name, cohort_desc, filters = "", cb_version = "v2")
cb_create_cohort(cohort_name, cohort_desc, filters = "", cb_version = "v2")
cohort_name |
New cohort name to be created. (Required) |
cohort_desc |
New cohort description to be created. (Optional) |
filters |
WIP - details will be added. |
cb_version |
cohort browser version. ["v1" | "v2"] (Optional) Default - "v2" |
A cohort object.
cb_load_cohort
for loading a available cohort.
## Not run: my_cohort <- cb_create_cohort(cohort_name = "Cohort-R", cohort_desc = "This cohort is for testing purpose, created from R.") ## End(Not run)
## Not run: my_cohort <- cb_create_cohort(cohort_name = "Cohort-R", cohort_desc = "This cohort is for testing purpose, created from R.") ## End(Not run)
Get Genotypic table in a dataframe. Optionally genotypic filters can be applied as well.
cb_get_genotypic_table(cohort, size = 10, geno_filters_query)
cb_get_genotypic_table(cohort, size = 10, geno_filters_query)
cohort |
A cohort object. (Required)
See constructor functions |
size |
Number of entries from database. (Optional) Default - 10 (Optional) |
geno_filters_query |
Genotypic filter query (Optional) |
A dataframe.
Get participant data table in a dataframe.
cb_get_participants_table(cohort, cols, page_number = "all", page_size = 5000)
cb_get_participants_table(cohort, cols, page_number = "all", page_size = 5000)
cohort |
A cohort object. (Required)
See constructor functions |
cols |
Vector of phenotype IDs to fetch as columns in the dataframe. If omitted, columns saved in the cohort are fetched. |
page_number |
Number of page as integer or 'all' to fetch all data. (Optional) Default - 'all' |
page_size |
Number of entries in a page. (Optional) Default - 5000 |
A dataframe.
Get participant data table in a longform dataframe.
cb_get_participants_table_long( cohort, cols, broadcast = TRUE, page_number = 0, page_size = 100 )
cb_get_participants_table_long( cohort, cols, broadcast = TRUE, page_number = 0, page_size = 100 )
cohort |
A cohort object. (Required)
See constructor functions |
cols |
Vector of phenotype IDs to fetch as columns in the dataframe. If omitted, columns saved in the cohort are fetched. |
broadcast |
Whether to broadcast single value phenotypes across rows. (Optional) Can be TRUE, FALSE or a vector of phenotype IDs to specify which phenotypes to broadcast. Default - TRUE |
page_number |
Number of page (can be 'all' to fetch all data) . (Optional) Default - 0 |
page_size |
Number of entries in a page. (Optional) Default - 10 |
A tibble.
Get the metadata of a phenotype in the cohort browser
cb_get_phenotype_metadata(pheno_id, cb_version = "v2")
cb_get_phenotype_metadata(pheno_id, cb_version = "v2")
pheno_id |
A phenotype ID. (Required) |
cb_version |
cohort browser version. (Default: "v2") [ "v1" | "v2" ] |
A data frame.
Retrieve a data frame containing the distirbution data for a specific phenotype within a cohort.
cb_get_phenotype_statistics( cohort, pheno_id, max_depth = Inf, page_number = "all", page_size = 1000 )
cb_get_phenotype_statistics( cohort, pheno_id, max_depth = Inf, page_number = "all", page_size = 1000 )
cohort |
A cohort object. (Required)
See constructor function |
pheno_id |
A phenotype ID. (Required) |
max_depth |
The maximum depth to descend in a 'nested list' phenotype. (Default: Inf) |
page_number |
For internal use. |
page_size |
For internal use. |
A data frame holding distribution data.
Extracts the data frame with limited cohort data columns.
cb_list_cohorts(size = 10, cb_version = "v2")
cb_list_cohorts(size = 10, cb_version = "v2")
size |
Number of cohort entries from database. (Optional) Default - 10 |
cb_version |
cohort browser version. ["v1" | "v2"] (Optional) Default - "v2" |
A data frame with available cohorts.
## Not run: cohorts_list() ## End(Not run)
## Not run: cohorts_list() ## End(Not run)
Get all the details about a cohort including applied query.
cb_load_cohort(cohort_id, cb_version = "v2")
cb_load_cohort(cohort_id, cb_version = "v2")
cohort_id |
Cohort id (Required) |
cb_version |
cohort browser version (Optional) [ "v1" | "v2" ] |
A cohort object.
cb_create_cohort
for creating a new cohort.
Returns the number of participants in a cohort if the supplied query were to be applied.
cb_participant_count(cohort, query = list(), keep_query = TRUE)
cb_participant_count(cohort, query = list(), keep_query = TRUE)
cohort |
A cohort object. (Required)
See constructor function |
query |
A phenotype query defined using the codephenotype function and logic operators (see example below) |
keep_query |
Apply newly specified query on top of exisiting query (Default: TRUE) |
A list with count of participants in the cohort and the total no. of participants in the dataset.
Get a list of ggplot objects, each plot having one filter.
cb_plot_filters(cohort)
cb_plot_filters(cohort)
cohort |
A cohort object. (Required)
See constructor function |
A list of ggplot objects
## Not run: my_cohort <- cb_load_cohort(cohort_id = "5f9af3793dd2dc6091cd17cd") plot_list <- cb_plot_filters(cohort = my_cohort) plot_list[[1]] library(ggpubr) ggpubr::ggarrange(plotlist = plot_list) ## End(Not run)
## Not run: my_cohort <- cb_load_cohort(cohort_id = "5f9af3793dd2dc6091cd17cd") plot_list <- cb_plot_filters(cohort = my_cohort) plot_list[[1]] library(ggpubr) ggpubr::ggarrange(plotlist = plot_list) ## End(Not run)
Search for phenotypes in the Cohort Browser that match your term and return a tibble containing the metadata information for each matching phenotype. Use ' term = "" ' to return all phenotypes.
cb_search_phenotypes(term, cb_version = "v2")
cb_search_phenotypes(term, cb_version = "v2")
term |
A term to search. (Required) |
cb_version |
cohort browser version (Optional) [ "v1" | "v2" ] |
A tibble with phenotype metadata
## Not run: cancer_phenos <- cb_search_phenotypes(term = "cancer") all_phenos <- cb_search_phenotypes(term = "") ## End(Not run)
## Not run: cancer_phenos <- cb_search_phenotypes(term = "cancer") all_phenos <- cb_search_phenotypes(term = "") ## End(Not run)
Updates a cohort by applying a new query.
cb_set_columns(cohort, column_ids, keep_columns = TRUE)
cb_set_columns(cohort, column_ids, keep_columns = TRUE)
cohort |
A cohort object. (Required)
See constructor function |
column_ids |
Vector of phenotype IDs to be added as columns in the participant table. |
keep_columns |
If True, pre-existing columns are retained and newly supplied columns are added. Otherwise, pre-exisitng columns are overwritten. (Default: TRUE) |
The updated cohort object.
## Not run: my_cohort <- cb_load_cohort(cohort_id = "612f37a57673ed0ddeaf1333", cb_version = "v2") my_cohort <- cb_set_columns(my_cohort, c(1, 99, 38), keep_columns = F) ## End(Not run)
## Not run: my_cohort <- cb_load_cohort(cohort_id = "612f37a57673ed0ddeaf1333", cb_version = "v2") my_cohort <- cb_set_columns(my_cohort, c(1, 99, 38), keep_columns = F) ## End(Not run)
On a system for the first time the cloudos configuration needed to be done. This function can help do that.
cloudos_configure(base_url, token, team_id)
cloudos_configure(base_url, token, team_id)
base_url |
Base URL for cloudos |
token |
API key or token |
team_id |
team/workspace ID |
None
To check the current configuration
cloudos_whoami()
cloudos_whoami()
None
This class creates a cohort object, which holds the information related to a
cohort: cohort ID, name, description, query, table columns. This class is used
in functions which carry out operations related to specific cohorts.
A cohort class object can be created using constructor functions
cb_create_cohort
or cb_load_cohort
.
id
cohort ID.
name
cohort name.
desc
cohort description.
phenoptype_filters
phenotypes displayed in the cohort overview.
query
applied query.
query_phenotype_ids
IDs of phenotypes used in the query.
columns
All the columns.
num_participants
number of participants in the cohort.
cb_version
chort browser version.
Defines a single phenotype
phenotype(id, value, from, to, instance = "0")
phenotype(id, value, from, to, instance = "0")
id |
A single phenotype id. Possible phenotyoes can be explored using the codecb_search_phenotypes function |
value |
The categorical value of the phenotype id defined |
from |
For continuous phenotypes, the lower bound of the desired value range |
to |
For continuous phenotypes, the upper bound of the desired value phenotype |
instance |
The instance number of the phenotype, default 0 |
A single phenotypes definition that cam be combined using &,| and ! operators
## Not run: continuous_phenotype <- phenotype(id = 13, from = "2016-01-21", to = "2017-02-13") categorical_phenotype <- phenotype(id = 4, value = "Cancer") ## End(Not run)
## Not run: continuous_phenotype <- phenotype(id = 13, from = "2016-01-21", to = "2017-02-13") categorical_phenotype <- phenotype(id = 4, value = "Cancer") ## End(Not run)