Skip to content

Commit

Permalink
Factominer applied for DEGs
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseCorCab committed Jan 25, 2024
1 parent 493f32b commit 30ef824
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 77 deletions.
12 changes: 12 additions & 0 deletions inst/templates/dea_results.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,18 @@ plot(evp)
```


```{r config_PCA_DEA, echo = FALSE, results = "asis", warning = TRUE, message = TRUE}
pca_data <- as.data.frame(t(all_data_normalized[["default"]]))
prevalen_degs <- rownames(DE_all_genes[DE_all_genes$genes_tag == "PREVALENT_DEG",])
pca_data <- pca_data[,prevalen_degs]
```

```{r child=file.path(template_folder,"facto_miner.Rmd")}
```


The complete results of the DEgenes Hunter differential expression analysis can be found in the "hunter\_results\_table.txt" file in the Common_results folder

Expand Down
74 changes: 2 additions & 72 deletions inst/templates/expression_qc.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ PerformanceAnalytics::chart.Correlation(raw_filter, histogram=TRUE, pch=19, log=
```



### **Heatmap and clustering showing correlation between replicates**
**BROWN: higher correlation; YELLOW: lower**

Expand All @@ -52,84 +50,16 @@ res <- cor(raw_filter)
gplots::heatmap.2(x = res, col = col, symm = TRUE, margins = rep(max(nchar(colnames(res))), 2), scale = "none", trace = "none")
```

### **Principal Component Analysis**
This is a PCA plot of the count values normalized following the default method and then they are scaled:

```{r pca_plot_FM, echo = FALSE, results = "asis", warning = TRUE, message = TRUE}
```{r config_PCA, echo = FALSE, results = "asis", warning = TRUE, message = TRUE}
pca_data <- as.data.frame(t(all_data_normalized[["default"]]))
std_pca <- FactoMineR::PCA(pca_data, scale.unit=TRUE, graph = FALSE)
dim_to_keep <- get_PCA_dimensions(std_pca)
rownames(target) <- as.character(target$sample)
string_factors <- final_main_params$string_factors
numeric_factors <- final_main_params$numeric_factors
pca_data <- merge_factors(pca_data, target, string_factors)
pca_data <- merge_factors(pca_data, target, numeric_factors)
full_pca <- FactoMineR::PCA(pca_data,ncp = dim_to_keep, scale.unit=TRUE, graph = FALSE, quanti.sup = numeric_factors, quali.sup=string_factors)
```
#### **Representation of the samples in the two first dimension of PCA**

```{r PCA_plot, echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
FactoMineR::plot.PCA(full_pca, invisible = "quali" , title = "")
```
#### **Representation of the samples and the categories of qualitative valiables in the two first dimension of PCA**

```{r PCA_extra_factors, echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
FactoMineR::plot.PCA(full_pca, title = "")
```

#### **Representation of the variable contribution to the PCA axis 1 and 2**

```{r PCA_num_var_1_2, echo = FALSE, warning =FALSE, message=FALSE, results = 'asis', eval = !is.null(numeric_factors)}
factoextra::fviz_pca_var(full_pca, axes = c(1, 2),select.var = list(name=numeric_factors), col.var="steelblue", title="") +
ggplot2::theme_minimal()
```

```{r PCA_num_var_3_4, echo = FALSE, warning =FALSE, message=FALSE, results = 'asis', eval = (dim_to_keep > 3 & !is.null(numeric_factors)) }
cat("#### **Representation of the variable contribution to the PCA axis 3 and 4**")
factoextra::fviz_pca_var(full_pca, axes = c(3, 4),select.var = list(name=numeric_factors), col.var="steelblue", title="") +
ggplot2::theme_minimal()
```


```{r biplot, echo = FALSE, warning =FALSE, message=FALSE, results = 'asis', eval = !is.null(numeric_factors)}
cat("#### **Representation of the individuals and the variable contribution to the PCA axis 1 and 2**")
factoextra::fviz_pca_biplot(full_pca, repel = TRUE,select.var = list(name=numeric_factors), col.var="steelblue", title="") +
ggplot2::theme_minimal()
```

```{r HC, echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
cat(paste("#### **Hierarchical clustering of individuals using first", dim_to_keep, "significant PCA dimensions**",sep=' '))
res.hcpc <- FactoMineR::HCPC(full_pca, graph = FALSE)
plot(res.hcpc , choice="tree", title="")
```

```{r HC_2, echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
cat(paste("#### **PCA representation of 1 and 2 axis with individuals coloured by its cluster membership. The first ", dim_to_keep, "significant PCA dimensions are used for HCPC**",sep=' '))
plot(res.hcpc , axes=c(1,2), choice="map", draw.tree= FALSE, title="")
```

```{r print_tables, echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
dim_data <- FactoMineR::dimdesc(full_pca, axes=seq(1, dim_to_keep))
dim_data_simp <- dim_data[grepl("Dim",names(dim_data))]
test <- lapply(names(dim_data_simp), parse_dim_table, dim_data = dim_data_simp, tag = "####")
```{r child=file.path(template_folder,"facto_miner.Rmd")}
```


The samples are shown in the 2D plane and distributed by their first two principal components. This type of plot is useful for visualizing the overall effect of experimental covariates and batch effects. It is also useful for identifying outlier samples. Control and treatment samples respectively may cluster together.

### **Visualizing normalization results**

Expand Down
78 changes: 78 additions & 0 deletions inst/templates/facto_miner.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@




### **Principal Component Analysis**
This is a PCA plot of the count values normalized following the default method and then they are scaled:

```{r , echo = FALSE, results = "asis", warning = TRUE, message = TRUE}
std_pca <- FactoMineR::PCA(pca_data, scale.unit=TRUE, graph = FALSE)
dim_to_keep <- get_PCA_dimensions(std_pca)
rownames(target) <- as.character(target$sample)
string_factors <- final_main_params$string_factors
numeric_factors <- final_main_params$numeric_factors
pca_data <- merge_factors(pca_data, target, string_factors)
pca_data <- merge_factors(pca_data, target, numeric_factors)
full_pca <- FactoMineR::PCA(pca_data,ncp = dim_to_keep, scale.unit=TRUE, graph = FALSE, quanti.sup = numeric_factors, quali.sup=string_factors)
```
#### **Representation of the samples in the two first dimension of PCA**

```{r , echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
FactoMineR::plot.PCA(full_pca, invisible = "quali" , title = "")
```

#### **Representation of the samples and the categories of qualitative valiables in the two first dimension of PCA**

```{r , echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
FactoMineR::plot.PCA(full_pca, title = "")
```

#### **Representation of the variable contribution to the PCA axis 1 and 2**

```{r , echo = FALSE, warning =FALSE, message=FALSE, results = 'asis', eval = !is.null(numeric_factors)}
factoextra::fviz_pca_var(full_pca, axes = c(1, 2),select.var = list(name=numeric_factors), col.var="steelblue", title="") +
ggplot2::theme_minimal()
```

```{r , echo = FALSE, warning =FALSE, message=FALSE, results = 'asis', eval = (dim_to_keep > 3 & !is.null(numeric_factors)) }
cat("#### **Representation of the variable contribution to the PCA axis 3 and 4**")
factoextra::fviz_pca_var(full_pca, axes = c(3, 4),select.var = list(name=numeric_factors), col.var="steelblue", title="") +
ggplot2::theme_minimal()
```


```{r , echo = FALSE, warning =FALSE, message=FALSE, results = 'asis', eval = !is.null(numeric_factors)}
cat("#### **Representation of the individuals and the variable contribution to the PCA axis 1 and 2**")
factoextra::fviz_pca_biplot(full_pca, repel = TRUE,select.var = list(name=numeric_factors), col.var="steelblue", title="") +
ggplot2::theme_minimal()
```

```{r , echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
cat(paste("#### **Hierarchical clustering of individuals using first", dim_to_keep, "significant PCA dimensions**",sep=' '))
res.hcpc <- FactoMineR::HCPC(full_pca, graph = FALSE)
plot(res.hcpc , choice="tree", title="")
```

```{r , echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
cat(paste("#### **PCA representation of 1 and 2 axis with individuals coloured by its cluster membership. The first ", dim_to_keep, "significant PCA dimensions are used for HCPC**",sep=' '))
plot(res.hcpc , axes=c(1,2), choice="map", draw.tree= FALSE, title="")
```

```{r , echo = FALSE, warning =FALSE, message=FALSE, results = 'asis'}
dim_data <- FactoMineR::dimdesc(full_pca, axes=seq(1, dim_to_keep))
dim_data_simp <- dim_data[grepl("Dim",names(dim_data))]
test <- lapply(names(dim_data_simp), parse_dim_table, dim_data = dim_data_simp, tag = "####")
```
10 changes: 5 additions & 5 deletions inst/templates/main_report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ output:
</style>


```{r child="expression_qc.Rmd"}
```{r child=file.path(template_folder,"expression_qc.Rmd")}
```

```{r child="dea_results.Rmd", eval = any(grepl("[DENL]",opt$modules))}
```{r child=file.path(template_folder,"dea_results.Rmd"), eval = any(grepl("[DENL]",opt$modules))}
```

```{r child="WGCNA_results.Rmd", eval = grepl("W", opt$modules)}
```{r child=file.path(template_folder,"WGCNA_results.Rmd"), eval = grepl("W", opt$modules)}
```

```{r child="diffcoexp_results.Rmd", eval = grepl("X", opt$modules)}
```{r child=file.path(template_folder,"diffcoexp_results.Rmd"), eval = grepl("X", opt$modules)}
```

```{r child="PCIT_results.Rmd", eval = grepl("P", opt$modules)}
```{r child=file.path(template_folder,"PCIT_results.Rmd"), eval = grepl("P", opt$modules)}
```

### **Values of options used to run DEGenesHunter**
Expand Down

0 comments on commit 30ef824

Please sign in to comment.