Skip to content

Commit

Permalink
Add an example of analysis workflow
Browse files Browse the repository at this point in the history
New package version 0.0.2
  • Loading branch information
mariaderrico committed Oct 13, 2021
1 parent 2d34611 commit 3a9e1dc
Show file tree
Hide file tree
Showing 4 changed files with 3,102 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: DPAclustR
Title: R interface to the Density Peaks Advanced (DPA) clustering in `Python`.
Version: 0.0.1
Version: 0.0.2
Authors@R:
person(given = "Maria",
family = "d'Errico",
Expand All @@ -27,4 +27,4 @@ Suggests:
networkD3 (>= 0.4),
testthat (>= 2.3.2)
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
62 changes: 62 additions & 0 deletions inst/analysis_workflow_example.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: "An example of analysis workflow"
author: "Maria d'Errico"
date: "10/12/2021"
output: html_document
---

```{r setup, include=TRUE}
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
reticulate::use_virtualenv("path_to_your_pyvirtualenv/venvdpa", required = TRUE)
DPA <- reticulate::import("Pipeline.DPA")
library(DPAclustR)
```

## Loading input and ground_truth file


```{r inputs}
df_features <- read.csv("extdata/features_tocluster_mascot.csv", header = TRUE)
df_gt <- read.csv("extdata/GT_features_tocluster_mascot.csv", header = TRUE)
ground_truth <- df_gt$Class
```

## Select main features and run DPA clustering


```{r DPA clustering, echo=TRUE}
data <- df_features[, c("I136.06232_pp", "I250.094014_pp", "I348.07091_pp", "I428.037241_pp", "log_DI583.082908_pp", "log_DI541.06111_pp", "log_DI347.063085_pp")]
results <- DPAclustR::runDPAclustering(data, Z=1, metric="euclidean", maxpop=NULL, dir=NULL)
```

## Plot results

Dendrogram

```{r dendrogram, echo=TRUE}
dendrogram <- DPAclustR::plot_dendrogram(results$labels, results$topography, maxD=max(results$density), popmin=5, method="average")
plot(dendrogram)
```

Network

```{r network, echo=TRUE}
ColourScale <- 'd3.scaleOrdinal()
.domain(["ADPr-Peptide", "randomPeptide"])
.range(["#FF6900", "#694489"]);'
DPAclustR::plot_networkD3(ground_truth, results$labels,
results$topography, popmin=5,
ukwn=NULL, opacity=0.8,
ColourScale=ColourScale)
```

## Evaluation of clustering results

```{r evaluation, echo=TRUE}
cm <- confusion_matrix(ground_truth, results$labels)
scores <- get_scores(ground_truth, results$labels)
print(cm)
print(scores)
```
Loading

0 comments on commit 3a9e1dc

Please sign in to comment.