Git Product home page Git Product logo

clusternomics's People

Contributors

evelinag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

clusternomics's Issues

numberOfClusters (based on use in vignette)

Hi,

the vignette has a use of the numberOfClusters function that does not seem to work. The code below is the setup as used in the vignette; I'll use a separate chunk to highlight issue.

library(clusternomics)
library(ggplot2)
library(dplyr)
set.seed(1)

# Number of elements in each cluster, follows the table given above
groupCounts <- c(50, 10, 40, 60)
# Centers of clusters
means <- c(-10.5,1.5)
# Helper function to generate test data
testData <- generateTestData_2D(groupCounts, means)
datasets <- testData$data

# Setup of the algorithm
dataDistributions <- 'diagNormal'
# Pre-specify number of clusters
clusterCounts <- list(global=10, context=c(3,3))
# Set number of iterations
# The following is ONLY FOR SIMULATION PURPOSES 
# Use larger number of iterations for real-life data
maxIter <- 300  
burnin <- 200
lag <- 2  # Thinning of samples

# Run context-dependent clustering
results <- contextCluster(datasets, clusterCounts, 
                          maxIter = maxIter, burnin = burnin, lag = lag,
                          dataDistributions = 'diagNormal',
                          verbose = F)

# Extract resulting cluster assignments
samples <- results$samples  

# Extract global cluster assignments for each MCMC sample
clusters <- lapply(1:length(samples), function(i) samples[[i]]$Global) 

This is how the numberOfClusters function is used:

cc <- numberOfClusters(clusters)

However, this creates an error as numberOfClusters refers to nrow(clusters); I think something like the following might be closer? I'm not sure though as there are some issues I'm finding in recreating the code from the vignette with this.

cc <- lapply(1:length(clusters), function(i) unique(clusters[[i]]) %>% length)

Possibly the issue is that clusters is a list of vectors rather than a data.frame? Or that I've done something mad. The last shouldn't be entirely discounted.

Number of datasets is different from number of contexts

First of all thanks for releasing the package.

I am trying to use it with 3 (or 4) context datasets and it fails with an error:

"
Number of datasets is different from number of contexts.
"

I traced it to line 84 in clusternomics.R where the length of the list is checked with number of datasets, but the length of the $context should be checked instead.

I tried to fix that and install from source and it seems to work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.