Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions R/get_diff_sites_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
qcdata <- ribo[[2]]

#----------------------------------------ANOVA test---------------------------
if(length(unique(qcdata$condition_col)) > 2){
if(length(unique(qcdata[[condition_col]])) > 2){
compute_pval_anova <- rRMSAnalyzer::compute_pval(ribo = ribo, test = "anova", condition_col = condition_col)
a <-rRMSAnalyzer::plot_stat(ribo = ribo, compute_pval = compute_pval_anova, pthr = pthr, condition_col = condition_col, cscore_cutoff = cscore_cutoff)
sites_anova <- a[["plot_env"]][["significant_sites"]]
}

#----------------------------------------Welch test---------------------------
Expand All @@ -57,9 +58,10 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
}

#----------------------------------------Kruskal test-------------------------
if(length(unique(qcdata$condition_col)) > 2){
if(length(unique(qcdata[[condition_col]])) > 2){
compute_pval_kruskal <- rRMSAnalyzer::compute_pval(ribo = ribo, test = "kruskal", condition_col = condition_col)
k <-rRMSAnalyzer::plot_stat(ribo = ribo, compute_pval = compute_pval_kruskal, pthr = pthr, condition_col = condition_col, cscore_cutoff = cscore_cutoff)
sites_kw <- k[["plot_env"]][["significant_sites"]]
}

#----------------------------------------Wilcoxon test------------------------
Expand All @@ -75,9 +77,9 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con

ribo_filtered_x <- keep_ribo_samples(ribo_filtered_x,kept_samples_x)

compute_pval_wolcoxon <- rRMSAnalyzer::compute_pval(ribo = ribo_filtered_x, test = "wilcoxon", condition_col = condition_col)
compute_pval_wilcoxon <- rRMSAnalyzer::compute_pval(ribo = ribo_filtered_x, test = "wilcoxon", condition_col = condition_col)

x <- rRMSAnalyzer::plot_stat(ribo = ribo_filtered_x, compute_pval = compute_pval_wolcoxon, pthr = pthr, condition_col = condition_col, cscore_cutoff = cscore_cutoff)
x <- rRMSAnalyzer::plot_stat(ribo = ribo_filtered_x, compute_pval = compute_pval_wilcoxon, pthr = pthr, condition_col = condition_col, cscore_cutoff = cscore_cutoff)
x_list[[i]] <- x
}

Expand All @@ -92,8 +94,8 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
comp_id <- paste0(case, "_vs_", ctrl)

# Extract significant sites from tests
sites_welch <- w_list[[i]][["plot_env"]][["significant_sites"]]
sites_wilcox <- x_list[[i]][["plot_env"]][["significant_sites"]]
sites_welch <- unique(unlist(lapply(w_list, function(w) w[["plot_env"]][["significant_sites"]])))
sites_wilcox <- unique(unlist(lapply(x_list, function(x) x[["plot_env"]][["significant_sites"]])))

# Add to the list
comparison_results[[comp_id]] <- list(
Expand All @@ -106,15 +108,13 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
results <- list()

# Identify all significant sites in at least on test
if(length(unique(qcdata$condition_col)) > 2){
if(length(unique(qcdata[[condition_col]])) > 2){
sites_anova <- a[["plot_env"]][["significant_sites"]]
sites_kw <- k[["plot_env"]][["significant_sites"]]
}
sites_welch <- w_list[[i]][["plot_env"]][["significant_sites"]]
sites_wilcox <- x_list[[i]][["plot_env"]][["significant_sites"]]

# all sites
if(length(unique(qcdata$condition_col)) > 2){
if(length(unique(qcdata[[condition_col]])) > 2){
all_sites <- unique(c(sites_anova, sites_kw, sites_welch, sites_wilcox))
} else {
all_sites <- unique(c(sites_welch, sites_wilcox))
Expand All @@ -124,7 +124,7 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
results$Site <- all_sites

# Add Anova et Kruskal column if groups > 2
if (length(unique(qcdata$condition_col)) > 2) {
if (length(unique(qcdata[[condition_col]])) > 2) {
results$Multiple_comparison_Anova <- ifelse(all_sites %in% sites_anova, "Significant", "NS")
results$Multiple_comparison_Kruskal_Wallis <- ifelse(all_sites %in% sites_kw, "Significant", "NS")
}
Expand Down
2 changes: 1 addition & 1 deletion inst/rmd/diff_sites.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ All resulting p-values were adjusted for multiple testing using the False Discov
<br>
\> Summary of Differentially Methylated rRNA 2′Ome Sites > (Only significant sites in at least one test are shown)

```{r}
```{r, warning=FALSE, message=FALSE}
summary_table <- rRMSAnalyzer::get_diff_sites_summary(ribo = ribo_to_check, condition_col = params$condition_col, comparisons = params$comparisons)

DT::datatable(
Expand Down
15 changes: 9 additions & 6 deletions vignettes/Model_human.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ ribo_adj_small <- keep_ribo_samples(ribo_adj,c("sample1","sample2","sample3","sa
### To remove a small number of samples

```{r, eval=FALSE}
ribo_adj_small <- remove_ribo_samples(ribo_adj,c("xxxx","xxxccc","RNA_ref-1","RNA_ref-2"))
ribo_adj_small <- remove_ribo_samples(ribo_adj,c("xxxx","xxxccc","RNA_ref-1","RNA_ref-2")) # ribo_toy : ...,c("RNA1", "RNA2"))
```

### Uniformisation of the RiboClass name
Expand Down Expand Up @@ -211,10 +211,12 @@ To do only if you want to compare a subset of your samples (i.e., not all the sa

```{r, eval=FALSE}
kept_samples <- ribo_adj_annot$metadata %>%
dplyr::filter(!is.na(variableA)) %>% # keep lines that are not "NA"
# keep lines that are not "NA"
dplyr::filter(!is.na(variableA)) %>% #ribo_toy (!is.na(comp1))
dplyr::pull(samplename)

ribo_adj_annot_variableA <- keep_ribo_samples(ribo_adj_annot,kept_samples) #create a new RiboClass including the subdata variableA
#create a new RiboClass including the subdata variableA
ribo_adj_annot_variableA <- keep_ribo_samples(ribo_adj_annot,kept_samples) #ribo_toy ribo_adj_annot_comp1 <- ...
```

#### Create mandatory comparison table for the report_diff_sites
Expand All @@ -231,15 +233,16 @@ comparisons <- tibble::tibble(

```{r, eval=FALSE}
report_2ome_sites(ribo = ribo_adj_annot_variableA, specie = "human", condition_col = "variableA", project_name = "name", comments = "./path/to/comment_2ome_variableA.Rmd")
#condition_col: change the name of the column to perform new analysis
#condition_col: change the name of the column to perform new analysis. ribo_toy condition_col = "comp1"
#comments: change the path and name of your files with your comments if required
```

#### Generate a report to perform site-by-site 2’Ome comparison

```{r, eval=FALSE}
report_diff_sites(ribo = ribo_adj_annot_variableA, specie = "human", condition_col = "variableA", project_name = "name", comparisons = comparisons, comments = "./comment_diff_site_variableA.Rmd")
#condition_col: change the name of the column to perform new analysis
#ribo_toy : ribo = ribo_adj_annot_comp1
#condition_col: change the name of the column to perform new analysis . ribo_toy condition_col = "comp1"
#comparisons: name of the comparison table
#comments: change the name of your files with your comments if required
```
Expand All @@ -251,7 +254,7 @@ Re-do all the steps of [Reports for comparisons explained in column 1] but using
## Export data

```{r, eval = FALSE}
ribo_df <- extract_data(ribo_adj_annot,
ribo_df <- extract_data(ribo_adj_annot, #change for the annotated RiboClass if needed
col = "cscore",
only_annotated = TRUE)

Expand Down