Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set data method does support only TRUE/FALSE annotations with list of names provided #33

Open
denklewer opened this issue Jul 26, 2024 · 0 comments

Comments

@denklewer
Copy link
Member

Current version does not support sample annotations with other values than boolean.

The code

H <- matrix(runif(K * N, min = 0, max = 1), nrow = K )  
W <- t(matrix(runif(K * M, min = 0, max = 10), nrow = K ) )
rownames(W) <- paste("gene", c(1:dim(W)[[1]]))
colnames(H) <- paste( "sample", c(1:dim(H)[[2]]))

# specify pure samples
H[,1] <-  c(1, 0, 0, 0)
H[,2] <-  c(0, 1, 0, 0)
H[,3] <-  c(0, 0, 1, 0)
H[,4] <-  c(0, 0, 1, 0)
H[,5] <-  c(0.2, 0.3, 0.2, 0.3)
V <- W %*% H
sample_annotation <- list(
  sample_name = colnames(V),
  proportions = unlist(lapply(colnames(H), function(sample_name) {
    return(paste((round(100*H[, sample_name]/sum(H[, sample_name]), digits=0)), collapse="|" ))
  })),
  original_corner = unlist(lapply(colnames(H), function(sample_name) { 
    sum((H[, sample_name]/sum(H[, sample_name])) == 1) == 1}))
)
dso <-  DualSimplexSolver$new()
dso$set_data(V, sinkhorn_iterations = 20, sample_anno_lists = sample_annotation)

will cast all annotations provided to TRUE/FALSE

image

The workaround is to set it afterwards manually.

sample_annotation <-  as.data.frame(sample_annotation)
current_anno <- pData(dso$get_data())
current_anno[,colnames(sample_annotation)] <-  sample_annotation
dso$st$data <- set_anno(anno=current_anno, eset=dso$get_data(), genes = F)

However it would be great to have the ability to provide it in advance

Expected picture is
image

@denklewer denklewer changed the title Set data method does not support any annotations except TRUE/FALSE Set data method does support only TRUE/FALSE annotations with list of names provided Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant