Skip to content

Commit a308b15

Browse files
Merge pull request #15 from RibosomeCRCL/Dev_Allyson
Dev allyson
2 parents 19069d2 + 41f2d4d commit a308b15

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

R/get_diff_sites_summary.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ get_diff_sites_summary <- function(ribo = ribo, pthr = 0.05, condition_col = con
3232
qcdata <- ribo[[2]]
3333

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

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

5960
#----------------------------------------Kruskal test-------------------------
60-
if(length(unique(qcdata$condition_col)) > 2){
61+
if(length(unique(qcdata[[condition_col]])) > 2){
6162
compute_pval_kruskal <- rRMSAnalyzer::compute_pval(ribo = ribo, test = "kruskal", condition_col = condition_col)
6263
k <-rRMSAnalyzer::plot_stat(ribo = ribo, compute_pval = compute_pval_kruskal, pthr = pthr, condition_col = condition_col, cscore_cutoff = cscore_cutoff)
64+
sites_kw <- k[["plot_env"]][["significant_sites"]]
6365
}
6466

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

7678
ribo_filtered_x <- keep_ribo_samples(ribo_filtered_x,kept_samples_x)
7779

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

80-
x <- rRMSAnalyzer::plot_stat(ribo = ribo_filtered_x, compute_pval = compute_pval_wolcoxon, pthr = pthr, condition_col = condition_col, cscore_cutoff = cscore_cutoff)
82+
x <- rRMSAnalyzer::plot_stat(ribo = ribo_filtered_x, compute_pval = compute_pval_wilcoxon, pthr = pthr, condition_col = condition_col, cscore_cutoff = cscore_cutoff)
8183
x_list[[i]] <- x
8284
}
8385

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

9496
# Extract significant sites from tests
95-
sites_welch <- w_list[[i]][["plot_env"]][["significant_sites"]]
96-
sites_wilcox <- x_list[[i]][["plot_env"]][["significant_sites"]]
97+
sites_welch <- unique(unlist(lapply(w_list, function(w) w[["plot_env"]][["significant_sites"]])))
98+
sites_wilcox <- unique(unlist(lapply(x_list, function(x) x[["plot_env"]][["significant_sites"]])))
9799

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

108110
# Identify all significant sites in at least on test
109-
if(length(unique(qcdata$condition_col)) > 2){
111+
if(length(unique(qcdata[[condition_col]])) > 2){
110112
sites_anova <- a[["plot_env"]][["significant_sites"]]
111113
sites_kw <- k[["plot_env"]][["significant_sites"]]
112114
}
113-
sites_welch <- w_list[[i]][["plot_env"]][["significant_sites"]]
114-
sites_wilcox <- x_list[[i]][["plot_env"]][["significant_sites"]]
115115

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

126126
# Add Anova et Kruskal column if groups > 2
127-
if (length(unique(qcdata$condition_col)) > 2) {
127+
if (length(unique(qcdata[[condition_col]])) > 2) {
128128
results$Multiple_comparison_Anova <- ifelse(all_sites %in% sites_anova, "Significant", "NS")
129129
results$Multiple_comparison_Kruskal_Wallis <- ifelse(all_sites %in% sites_kw, "Significant", "NS")
130130
}

inst/rmd/diff_sites.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ All resulting p-values were adjusted for multiple testing using the False Discov
504504
<br>
505505
\> Summary of Differentially Methylated rRNA 2′Ome Sites > (Only significant sites in at least one test are shown)
506506

507-
```{r}
507+
```{r, warning=FALSE, message=FALSE}
508508
summary_table <- rRMSAnalyzer::get_diff_sites_summary(ribo = ribo_to_check, condition_col = params$condition_col, comparisons = params$comparisons)
509509
510510
DT::datatable(

vignettes/Model_human.Rmd

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ ribo_adj_small <- keep_ribo_samples(ribo_adj,c("sample1","sample2","sample3","sa
154154
### To remove a small number of samples
155155

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

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

212212
```{r, eval=FALSE}
213213
kept_samples <- ribo_adj_annot$metadata %>%
214-
dplyr::filter(!is.na(variableA)) %>% # keep lines that are not "NA"
214+
# keep lines that are not "NA"
215+
dplyr::filter(!is.na(variableA)) %>% #ribo_toy (!is.na(comp1))
215216
dplyr::pull(samplename)
216217
217-
ribo_adj_annot_variableA <- keep_ribo_samples(ribo_adj_annot,kept_samples) #create a new RiboClass including the subdata variableA
218+
#create a new RiboClass including the subdata variableA
219+
ribo_adj_annot_variableA <- keep_ribo_samples(ribo_adj_annot,kept_samples) #ribo_toy ribo_adj_annot_comp1 <- ...
218220
```
219221

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

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

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

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

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

0 commit comments

Comments
 (0)