diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..632fd5c --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,5 @@ +/.quarto/ +*.html +*.R +*_files +_quarto.yaml \ No newline at end of file diff --git a/vignettes/structure.qmd b/vignettes/structure.qmd new file mode 100644 index 0000000..c104338 --- /dev/null +++ b/vignettes/structure.qmd @@ -0,0 +1,133 @@ +--- +title: "Package structure" +vignette: > + %\VignetteIndexEntry{Package structure} + %\VignetteEncoding{UTF-8} + %\VignetteEngine{quarto::html} +editor_options: + chunk_output_type: console +knitr: + opts_chunk: + collapse: true + comment: "#>" +--- + +```{mermaid} +classDiagram + laminr --> RichInstance + laminr --> UserSettings + laminr --> InstanceSettings + RichInstance --|> Instance + Instance --> InstanceAPI + Instance --> Module + Core --|> Module + Bionty --|> Module + Module --> Registry + Registry --> Field + Registry --> RichRecord + Artifact --|> Record + RichInstance --> Core + RichInstance --> Bionty + Core --> Artifact + RichRecord --|> Record + + class laminr{ + +connect(String slug): RichInstance + } + + class UserSettings{ + +initialize(...): UserSettings + +email: String + +access_token: String + +uid: String + +uuid: String + +handle: String + +name: String + } + + class InstanceSettings{ + +initialize(...): InstanceSettings + +owner: String + +name: String + +id: String + +schema_id: String + +api_url: String + } + class Instance{ + +initialize(InstanceSettings Instance_settings, API api, Map schema): Instance + +get_modules(): Module[] + +get_module(String module_name): Module + +get_module_names(): String[] + + } + class InstanceAPI{ + +initialize(InstanceSettings Instance_settings) + +get_schema(): Map~String, Any~ + +get_record(...): Map~String, Any~ + } + class RichInstance{ + +initialize(InstanceSettings Instance_settings, API api, Map schema): RichInstance + +Registry Artifact + +Registry Collection + +...registry accessors... + +Registry User + +Bionty bionty + } + class Core{ + +Registry Artifact + +Registry Collection + +...registry accessors... + +Registry User + } + class Bionty{ + +Registry CellLine + +Registry CellMarker + +...registry accessors... + +Registry Tissue + } + class Module{ + +initialize(Instance Instance, API api, String module_name, Map module_schema): Module + +name: String + +get_registries(): Registry[] + +get_registry(String registry_name): Registry + +get_registry_names(): String[] + } + class Registry{ + +initialize(Instance Instance, Module module, API api, String registry_name, Map registry_schema): Registry + +name: String + +class_name: String + +is_link_table: Bool + +get_fields(): Field[] + +get_field(String field_name): Field + +get_field_names(): String[] + +get(String id_or_uid, Bool include_foreign_keys, List~String~ select, Bool verbose): RichRecord + +get_registry_class(): RichRecordClass + } + class Artifact{ + +initialize(...): Artifact + +cache(): String + +load(): Any + } + class Field{ + +initialize(...): Field + +type: String + +through: Map + +field_name: String + +registry_name: String + +column_name: String + +module_name: String + +is_link_table: Bool + +relation_type: String + +related_field_name: String + +related_registry_name: String + +related_module_name: String + + } + class RichRecord{ + +...field value accessors... + } + class Record{ + +initialize(Instance Instance, Registry registry, API api, Map data): Record + +get_value(String field_name): Any + } +``` diff --git a/vignettes/usage.qmd b/vignettes/usage.qmd new file mode 100644 index 0000000..566ba65 --- /dev/null +++ b/vignettes/usage.qmd @@ -0,0 +1,104 @@ +--- +title: "Usage" +vignette: > + %\VignetteIndexEntry{Usage} + %\VignetteEncoding{UTF-8} + %\VignetteEngine{quarto::html} +editor_options: + chunk_output_type: console +knitr: + opts_chunk: + collapse: true + comment: "#>" +--- + +```{r setup} +library(laminr) +``` + +## Instance + +### Connect to a LaminDB instance + +```{r connect} +db <- connect("laminlabs/cellxgene") +``` + + +### Print a LaminDB instance + +```{r print_instance} +db +``` + +### Get module + +```{r get_module} +db$get_module("core") + +db$bionty +``` + +## Registry + +```{r get_artifact_registry} +db$Artifact +``` + +```{r get_bionty_celline} +db$bionty$CellLine +``` + +## Record + +### Get artifact + +```{r get_artifact} +artifact <- db$Artifact$get("KBW89Mf7IGcekja2hADu") +``` + +### Print artifact + +```{r print_artifact} +artifact +``` + +### Print simple fields + +```{r print_simple_fields} +artifact$id + +artifact$uid + +artifact$key +``` + +### Print related fields + +```{r print_related_fields} +artifact$storage + +artifact$created_by + +artifact$experimental_factors +``` + +### Cache artifact + +:::{.callout-note} +Only S3 storage is supported at the moment. +::: + +```{r cache_artifact} +artifact$cache() +``` + +### Load artifact + +:::{.callout-note} +Only S3 storage and AnnData accessors are supported at the moment. +::: + +```{r load_artifact} +artifact$load() +```