Skip to content

Commit

Permalink
Fixed issue where opticluster was returning a matrix array and not a …
Browse files Browse the repository at this point in the history
…data.frame.
  • Loading branch information
GregJohnsonJr committed Apr 26, 2024
1 parent 3a4db38 commit 11b7210
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion R/Cluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ OptiCluster <- function(sparse_matrix, cutoff, iterations)
matrix_length <- length(indexOneList)
clustering_output_string <- MatrixToOpiMatrixCluster(indexOneList, indexTwoList, valueList, cutoff,
matrix_length, matrix_length, iterations)
return(t(read.table(text = clustering_output_string, sep = "\t", header = TRUE)))
df <- data.frame(t(read.table(text = clustering_output_string, sep = "\t", header = TRUE)))
colnames(df)[1] <- "cluster"
return(df)
}
Binary file modified tests/extdata/df_test_file.RDS
Binary file not shown.
3 changes: 1 addition & 2 deletions tests/testthat/test-test-opticluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ test_that("Clustering returns proper results", {
expected_df <- readRDS(here::here("tests/extdata/df_test_file.RDS"))
matrix <- readRDS(here::here("tests/extdata/matrix_data.RDS"))
df <- Opticluster::OptiCluster(matrix, 0.2, 2)
list <- c("matrix", "array")
expect_equal(class(df), list)
expect_equal(class(df), "data.frame")
expect_equal(df, expected_df)
})

0 comments on commit 11b7210

Please sign in to comment.