Skip to content

Commit

Permalink
added tibble library into vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristinaSchmidt1 committed Oct 31, 2024
1 parent 5c8badc commit e952d13
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions vignettes/Standard Metabolomics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ library(magrittr)
library(dplyr)
library(rlang)
library(ggfortify)
library(tibble)
#Please install the Biocmanager Dependencies:
#BiocManager::install("clusterProfiler")
Expand Down Expand Up @@ -363,7 +364,7 @@ for(comparison in comparisons){
dplyr::rename("Metabolite"="KEGGCompound")#We use the KEGG trivial names to match with the KEGG pathways
#Perform ORA
DM_ORA_res[[comparison]] <- MetaProViz::StandardORA(InputData= DMA%>%remove_rownames()%>%column_to_rownames("Metabolite"), #Input data requirements: column `t.val` and column `Metabolite`
DM_ORA_res[[comparison]] <- MetaProViz::StandardORA(InputData= DMA%>%remove_rownames()%>%tibble::column_to_rownames("Metabolite"), #Input data requirements: column `t.val` and column `Metabolite`
SettingsInfo=c(pvalColumn="p.adj", PercentageColumn="t.val", PathwayTerm= "term", PathwayFeature= "Metabolite"),
PathwayFile=KEGG_Pathways,#Pathway file requirements: column `term`, `Metabolite` and `Description`. Above we loaded the Kegg_Pathways using MetaProViz::Load_KEGG()
PathwayName="KEGG",
Expand Down Expand Up @@ -461,7 +462,7 @@ MappingInfo[1:6,]%>%
```

```{r, include=FALSE, warning=FALSE}
MC_ORA_result <- MetaProViz::ClusterORA(InputData=MCAres[["MCA_2Cond_Results"]]%>%column_to_rownames("Metabolite"),
MC_ORA_result <- MetaProViz::ClusterORA(InputData=MCAres[["MCA_2Cond_Results"]]%>%tibble::column_to_rownames("Metabolite"),
SettingsInfo=c(ClusterColumn="RG2_Significant",
BackgroundColumn="BG_Method",
PathwayTerm= "Pathway", #This is the column name including the pathways names
Expand Down Expand Up @@ -498,8 +499,8 @@ MetaData_Sample%>%
\
Moreover, we can use MetaData for our features (=Metabolites), which we loaded with the `MappingInfo` and we can also add the information on which cluster a metabolite was assigned to in the `MetaProViz::MCA()` analysis above:\
```{r}
MetaData_Metab <-merge(MappingInfo%>%rownames_to_column("Metabolite"), MCAres[["MCA_2Cond_Results"]][,c(1, 14,15)], by="Metabolite", all.y=TRUE)%>%
column_to_rownames("Metabolite")
MetaData_Metab <-merge(MappingInfo%>%tibble::rownames_to_column("Metabolite"), MCAres[["MCA_2Cond_Results"]][,c(1, 14,15)], by="Metabolite", all.y=TRUE)%>%
tibble::column_to_rownames("Metabolite")
```
```{r, echo=FALSE}
# Check how our data looks like:
Expand Down Expand Up @@ -734,20 +735,20 @@ DM_ORA_res[["786-M1A_vs_HK2"]][["ClusterGoSummary"]][1:4,-c(1,7)]%>%
Here we will first look into the results from the differential analysis (see section `DMA` above) for the comparison of `786-M1A_vs_HK2`:
```{r, fig.align="left", fig.width=7, fig.height=5, fig.cap="Figure: Standard figure displaying DMA results."}
# Run with default parameter --> only need to provide Input_data and the title we like
MetaProViz::VizVolcano(InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"))
MetaProViz::VizVolcano(InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"))
```
\
If you seek to plot the metabolite names you can change the paramter `SelectLab` from its default (`SelectLab=""`) to NULL and the metabolite names will be plotted randomly.
```{r, fig.align="left", fig.width=7, fig.height=5, fig.cap="Figure: Standard figure displaying DMA results."}
# Run with default parameter --> only need to provide Input_data and the title we like
MetaProViz::VizVolcano(InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
MetaProViz::VizVolcano(InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
SelectLab = NULL)
```
\
With the parameter `SelectLab` you can also pass a vector with Metabolite names that should be labeled:
```{r, fig.align="left", fig.width=7, fig.height=5, fig.cap="Figure: Standard figure displaying DMA results."}
# Run with default parameter --> only need to provide Input_data and the title we like
MetaProViz::VizVolcano(InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
MetaProViz::VizVolcano(InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
SelectLab = c("N-acetylaspartylglutamate", "cystathionine", "orotidine"))
```
\
Expand All @@ -758,23 +759,23 @@ Next we may be interested to understand which metabolite clusters based on our M
MetaProViz::VizVolcano(PlotSettings="Standard",
SettingsInfo= c(color="RG2_Significant"),
SettingsFile_Metab= MetaData_Metab,
InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
PlotName= "786M1A versus HK2",
Subtitle= "Results of DMA. Colour coded for metabolic clusters" )
#If we want to use the shape instead of the colour for the cluster info, we can just change our Plot_SettingsInfo
MetaProViz::VizVolcano(PlotSettings="Standard",
SettingsInfo= c(shape="RG2_Significant"),
SettingsFile= MetaData_Metab,
InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
PlotName= "786M1A versus HK2",
Subtitle= "Results of DMA. Shape for metabolic clusters, color for significance." )
#Of course, we can also adapt both, color and shape for the same parameter:
MetaProViz::VizVolcano(PlotSettings="Standard",
SettingsInfo= c(shape="RG2_Significant", color="RG2_Significant"),
SettingsFile= MetaData_Metab,
InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
PlotName= "786M1A versus HK2",
Subtitle= "Results of DMA. Shape and color for metabolic clusters." )
```
Expand All @@ -785,7 +786,7 @@ Given that we also know, which metabolic pathway the metabolites correspond to,
MetaProViz::VizVolcano(PlotSettings="Standard",
SettingsInfo= c(color="Pathway"),
SettingsFile_Metab= MappingInfo,
InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
PlotName= "786M1A versus HK2 Results of DMA. Colour for metabolic pathways.",
Subtitle= "Results of DMA. Colour for metabolic pathways." )
```
Expand All @@ -796,7 +797,7 @@ We immediately see that there are many pathways displayed on the plot, which can
MetaProViz::VizVolcano(PlotSettings="Standard",
SettingsInfo= c(color="RG2_Significant", individual="Pathway"),
SettingsFile_Metab= MetaData_Metab,
InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
PlotName= "786M1A versus HK2",
Subtitle= "Results of DMA. Colour for metabolic pathways." )
```
Expand All @@ -807,7 +808,7 @@ MetaProViz::VizVolcano(PlotSettings="Standard",
MetaProViz::VizVolcano(PlotSettings="Standard",
SettingsInfo= c(color="RG2_Significant", individual="Pathway"),
SettingsFile_Metab= MetaData_Metab,
InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
PlotName= "786M1A versus HK2",
Subtitle= "Results of DMA. Colour for metabolic pathways." )
Expand All @@ -820,8 +821,8 @@ MetaProViz::VizVolcano(PlotSettings="Standard",
#### **Comparison**
```{r, fig.align="left", fig.width=7, fig.height=5, fig.cap="Figure: Comparison."}
MetaProViz::VizVolcano(PlotSettings="Compare",
InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
InputData2= DMA_Annova[["DMA"]][["786-O_vs_HK2"]]%>%column_to_rownames("Metabolite"),
InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
InputData2= DMA_Annova[["DMA"]][["786-O_vs_HK2"]]%>%tibble::column_to_rownames("Metabolite"),
ComparisonName= c(InputData="786M1A_vs_HK", InputData2= "786-O_vs_HK2"),
PlotName= "786M1A vs HK2 compared to 7860 vs HK2",
Subtitle= "Results of DMA" )
Expand All @@ -832,8 +833,8 @@ Now we do individual plots again:
MetaProViz::VizVolcano(PlotSettings="Compare",
SettingsInfo= c(individual="Pathway"),
SettingsFile_Metab= MappingInfo,
InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
InputData2= DMA_Annova[["DMA"]][["786-O_vs_HK2"]]%>%column_to_rownames("Metabolite"),
InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
InputData2= DMA_Annova[["DMA"]][["786-O_vs_HK2"]]%>%tibble::column_to_rownames("Metabolite"),
PlotName= "786M1A vs HK2 compared to 7860 vs HK2",
Subtitle= "Results of DMA" )
```
Expand All @@ -843,8 +844,8 @@ MetaProViz::VizVolcano(PlotSettings="Compare",
MetaProViz::VizVolcano(PlotSettings="Compare",
SettingsInfo= c(individual="Pathway"),
SettingsFile_Metab= MappingInfo,
InputData=DMA_786M1A_vs_HK2%>%column_to_rownames("Metabolite"),
InputData2= DMA_Annova[["DMA"]][["786-O_vs_HK2"]]%>%column_to_rownames("Metabolite"),
InputData=DMA_786M1A_vs_HK2%>%tibble::column_to_rownames("Metabolite"),
InputData2= DMA_Annova[["DMA"]][["786-O_vs_HK2"]]%>%tibble::column_to_rownames("Metabolite"),
PlotName= "786M1A vs HK2 compared to 7860 vs HK2",
Subtitle= "Results of DMA" )
Expand All @@ -861,7 +862,7 @@ For this we need to prepare the correct input data including the pathways used t
#1. InputData=Pathway analysis input: Must have features as column names. Those feature names need to match features in the pathway analysis file SettingsFile_Metab.
InputPEA <- DMA_786M1A_vs_HK2 %>%
filter(!is.na(KEGGCompound)) %>%
column_to_rownames("KEGGCompound")
tibble::column_to_rownames("KEGGCompound")
#2. InputData2=Pathway analysis output: Must have same column names as SettingsFile_Metab for Pathway name
InputPEA2 <- DM_ORA_786M1A_vs_HK2 %>%
Expand Down

0 comments on commit e952d13

Please sign in to comment.