nsh87 / receptormarker

Source for 'receptormarker' package for R: antibody receptor and phenotypic marker analysis
http://receptormarker.com
BSD 2-Clause "Simplified" License
4 stars 9 forks source link

Create testing for cluster-related functions and add Fluidigm data #22

Closed catterbu closed 9 years ago

catterbu commented 9 years ago

The validation functions, the multi_clust function, and all cluster plotting functions have tests to ensure that they are not broken in future updates.

nsh87 commented 9 years ago

This works:

context("Unit test cluster plotting")

tryCatch({
    set.seed(1)
    data(fluidigm)
    fluidigm <- fluidigm[1:25,]
    f_clust <- multi_clust(fluidigm, krange = 2:4)
  },
  finally = {
    set.seed(NULL)  # Turn off seed
  }
)

test_that("wss plots properly", {
  expected_hash <- "47d160c26197e5ef76cd8d0416f56774"
  file_path <- tempfile(pattern="wss_plot", tmpdir=tempdir(), fileext=".png")
  png(file_path, width=480, height=480, antialias="none")
  wss_plot(f_clust, optimal=FALSE)
  dev.off()
  test_hash <- digest::digest(file.info(file_path)[["size"]], algo="md5")
  expect_that(expected_hash, equals(test_hash))
})
catterbu commented 9 years ago

@nsh87 Assuming nothing goes wrong with travis, this should be ready to merge now.

catterbu commented 9 years ago

@nsh87 I am hesistant to write anything after it got rejected before for something that I thought I had already fixed, but this passed the tests on my local. If travis is kind, this should be ready.