Browse code

Added min_pts argument

Shians authored on 10/05/2023 00:27:54
Showing 2 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: NanoMethViz
2 2
 Type: Package
3 3
 Title: Visualise methlation data from Oxford Nanopore sequencing
4
-Version: 2.5.7
4
+Version: 2.5.8
5 5
 Authors@R: c(
6 6
     person("Shian", "Su", email = "[email protected]", role = c("cre", "aut")))
7 7
 Description: NanoMethViz is a toolkit for visualising methylation data from 
... ...
@@ -1,4 +1,4 @@
1
-cluster_reads <- function(x, chr, start, end) {
1
+cluster_reads <- function(x, chr, start, end, min_pts = 10) {
2 2
     methy_data <- query_methy(x, chr, start, end ) %>%
3 3
         filter(pos >= start & pos < end)
4 4
 
... ...
@@ -36,7 +36,7 @@ cluster_reads <- function(x, chr, start, end) {
36 36
         mod_mat_filled[i, is.na(mod_mat_filled[i, ])] <- mean(mod_mat_filled[i, ], na.rm = TRUE)
37 37
     }
38 38
 
39
-    dbsc <- dbscan::hdbscan(mod_mat_filled, minPts = 15)
39
+    dbsc <- dbscan::hdbscan(mod_mat_filled, minPts = min_pts)
40 40
     clust_df <- data.frame(read_name = rownames(mod_mat_filled), cluster_id = dbsc$cluster)
41 41
 
42 42
     out_df <- as.data.frame(mod_mat) %>%
... ...
@@ -52,5 +52,11 @@ cluster_reads <- function(x, chr, start, end) {
52 52
         dplyr::summarise(mean = mean(methy_prob, na.rm = TRUE)) %>%
53 53
         dplyr::left_join(clust_df, by = "read_name") %>%
54 54
         dplyr::left_join(read_stats, by = "read_name") %>%
55
-        dplyr::arrange(cluster_id)
55
+        dplyr::arrange(cluster_id) %>%
56
+        dplyr::mutate(
57
+            cluster_id = as.factor(cluster_id),
58
+            start = as.integer(start),
59
+            end = as.integer(end),
60
+            span = as.integer(span)
61
+        )
56 62
 }