--- title: "Getting Started with omicslog" author: "Juan Henao" date: "`r Sys.Date()`" package: omicslog output: BiocStyle::html_document: toc: true toc_float: true vignette: > %\VignetteIndexEntry{Getting Started with omicslog} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r set-up, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = TRUE, warning = TRUE ) ``` # Installation You can install the `omicslog` package from Bioconductor using the following commands: ```{r installation, eval=FALSE} if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager::install("omicslog") ``` # Introduction The `omicslog` package provides logging capabilities for `SingleCellExperiment` and `SummarizedExperiment` objects. This is particularly useful for tracking transformations in complex analysis workflows. ```{r loading-libraries, message=FALSE} library(SummarizedExperiment) library(tidySummarizedExperiment) library(omicslog) data(airway, package="airway") ``` ## Pipeline Workflow Omicslog logs chain operations in a pipeline workflow. Here's an example of a complete workflow using the `airway` dataset: ```{r tidy-operaitons, message=TRUE, warning=TRUE} # Complete workflow in a single pipeline result <- airway |> log_start() |> filter(dex == "untrt") |> select(!albut) |> mutate(dex_upper = toupper(dex)) |> extract(col = dex,into = "treat") |> mutate(Run = tolower(Run)) |> filter(.feature == "ENSG00000000003") |> slice(3) # View the object with the top log history as text result ``` ```{r visualizing-tidy-log, message=TRUE, warning=TRUE} # View the table with the complete log history print(result@log_history,width=Inf) ``` ## Base R Pipeline Here's the same workflow implemented using base R operations: ```{r base-operations, message=TRUE, warning=TRUE} # switch printing to Bioconductor style options(restore_SummarizedExperiment_show = TRUE) # Start with logging result_base <- log_start(airway) # Filter samples by dex result_base <- result_base[, colData(result_base)$dex == "untrt"] # Add new column with uppercase dex colData(result_base)$dex_upper <- toupper(colData(result_base)$dex) # Modify Run column to lowercase colData(result_base)$Run <- tolower(colData(result_base)$Run) # Filter features result_base <- result_base[rownames(result_base) == "ENSG00000000003", ] # View the object with the top log history as text result_base ``` ```{r visualizing-base-log, message=TRUE, warning=TRUE} # View the table with the complete log history print(result_base@log_history,width=Inf) ``` ```{r restoring-printing, echo=FALSE} # switch printing to Bioconductor style options(restore_SummarizedExperiment_show = FALSE) ``` # SingleCellExperiment Example `omicslog` also supports `SingleCellExperiment` objects. Here's an example using the `pbmc_small` dataset: ```{r single-cell-example, message=TRUE, warning=TRUE} data(pbmc_small, package="tidySingleCellExperiment") pbmc_logged <- log_start(pbmc_small) pbmc_logged <- pbmc_logged[, colData(pbmc_logged)$groups == "g1"] pbmc_logged <- pbmc_logged[rownames(pbmc_logged) %in% c("ENSG00000198888", "ENSG00000198786"), ] pbmc_logged ``` # Session Info ```{r session-info, echo=FALSE} sessionInfo() ```