---
title: "RSEM counts from RENEE"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{renee}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
options(rmarkdown.html_vignette.check_title = FALSE)
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(MOSuite)
library(dplyr)
```

## RENEE dataset

```{r data}
# replace these lines with the actual paths to your files
gene_counts_tsv <- system.file("extdata",
  "RSEM.genes.expected_count.all_samples.txt.gz",
  package = "MOSuite"
)
metadata_tsv <- system.file("extdata", "sample_metadata.tsv.gz",
  package = "MOSuite"
)

# create multi-omic object
moo <- create_multiOmicDataSet_from_files(
  sample_meta_filepath = metadata_tsv,
  feature_counts_filepath = gene_counts_tsv
)

head(moo@counts$raw)
head(moo@sample_meta)
head(moo@annotation)
```

```{r analysis}
moo <- moo |>
  clean_raw_counts() |>
  filter_counts(
    group_colname = "condition",
    label_colname = "sample_id",
    minimum_count_value_to_be_considered_nonzero = 1,
    minimum_number_of_samples_with_nonzero_counts_in_total = 1,
    minimum_number_of_samples_with_nonzero_counts_in_a_group = 1,
  ) |>
  normalize_counts(
    group_colname = "condition",
    label_colname = "sample_id"
  ) |>
  diff_counts(
    covariates_colnames = "condition",
    contrast_colname = "condition",
    contrasts = c("knockout-wildtype")
  ) |>
  filter_diff(
    significance_cutoff = 0.05,
    significance_column = "adjpval",
    change_column = "logFC",
    change_cutoff = 1
  )

moo@counts$norm$voom |> head()
```

## The multiOmicDataSet object structure

```{r str_moo}
str(moo)
```
