-
Notifications
You must be signed in to change notification settings - Fork 3
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
Embedding step #17
Embedding step #17
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Please respond to comments. Most suggestions are just coding style preferences that you are free to ignore
# Clustering part | ||
################# | ||
|
||
message("Running clustering") | ||
|
||
if(config$clusteringSettings$method=="louvain"){ | ||
clustering_method <- 1 #"Louvain" | ||
clustering_resolution <- config$clusteringSettings$methodSettings[["louvain"]]["resolution"] | ||
|
||
# HARDCODE | ||
annoy.metric = "cosine" | ||
scdata <- Seurat::FindNeighbors(scdata, k.param = 20, annoy.metric = annoy.metric, verbose=FALSE) | ||
scdata <- Seurat::FindClusters(scdata, resolution=clustering_resolution, verbose = FALSE, algorithm = clustering_method) | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably refactor this into a seperate function to break up the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me iterate!
########################## | ||
# Coloring active ident | ||
########################### | ||
if ("color_pool" %in% names(scdata@misc)){ | ||
color_pool <- scdata@misc[['color_pool']] | ||
}else{ # THIS SHOULD BE REMOVE ONCE THE EXPERIMENT HAS BEEN UPDATED WITH THE NEW VERSION OF THE DATA-INGEST | ||
color_pool <- c("#e377c2","#8c564b","#d62728","#2ca02c","#ff7f0e","#1f77b4","#f8e71c","#3957ff","#d3fe14", | ||
"#c9080a","#fec7f8","#0b7b3e","#0bf0e9","#c203c8","#fd9b39","#888593","#906407","#98ba7f","#fe6794","#10b0ff", | ||
"#ac7bff","#fee7c0","#964c63","#1da49c","#0ad811","#bbd9fd","#fe6cfe","#297192","#d1a09c","#78579e","#81ffad", | ||
"#739400","#ca6949","#d9bf01","#646a58","#d5097e","#bb73a9","#ccf6e9","#9cb4b6","#b6a7d4","#9e8c62","#6e83c8", | ||
"#01af64","#a71afd","#cfe589","#d4ccd1","#fd4109","#bf8f0e","#2f786e","#4ed1a5","#d8bb7d","#a54509","#6a9276", | ||
"#a4777a","#fc12c9","#606f15","#3cc4d9","#f31c4e","#73616f","#f097c6","#fc8772","#92a6fe","#875b44","#699ab3", | ||
"#94bc19","#7d5bf0","#d24dfe","#c85b74","#68ff57","#b62347","#994b91","#646b8c","#977ab4","#d694fd","#c4d5b5", | ||
"#fdc4bd","#1cae05","#7bd972","#e9700a","#d08f5d","#8bb9e1","#fde945","#a29d98","#1682fb","#9ad9e0","#d6cafe", | ||
"#8d8328","#b091a7","#647579","#1f8d11","#e7eafd","#b9660b","#a4a644","#fec24c","#b1168c","#188cc1","#7ab297", | ||
"#4468ae","#c949a6") | ||
|
||
} | ||
scdata$color_active_ident <- color_pool[as.numeric([email protected])] | ||
|
||
########################## | ||
# Coloring samples | ||
########################### | ||
remaining.colors <- color_pool[-c(1:length(unique([email protected]$color_active_ident)))] | ||
if ("type"%in%colnames([email protected])) # In that case we are in multisample experiment | ||
[email protected][, "color_samples"] <- remaining.colors[as.numeric(as.factor(scdata$type))] | ||
else | ||
[email protected][, "color_samples"] <- remaining.colors[1] | ||
|
||
return(scdata) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
########################## | |
# Coloring active ident | |
########################### | |
if ("color_pool" %in% names(scdata@misc)){ | |
color_pool <- scdata@misc[['color_pool']] | |
}else{ # THIS SHOULD BE REMOVE ONCE THE EXPERIMENT HAS BEEN UPDATED WITH THE NEW VERSION OF THE DATA-INGEST | |
color_pool <- c("#e377c2","#8c564b","#d62728","#2ca02c","#ff7f0e","#1f77b4","#f8e71c","#3957ff","#d3fe14", | |
"#c9080a","#fec7f8","#0b7b3e","#0bf0e9","#c203c8","#fd9b39","#888593","#906407","#98ba7f","#fe6794","#10b0ff", | |
"#ac7bff","#fee7c0","#964c63","#1da49c","#0ad811","#bbd9fd","#fe6cfe","#297192","#d1a09c","#78579e","#81ffad", | |
"#739400","#ca6949","#d9bf01","#646a58","#d5097e","#bb73a9","#ccf6e9","#9cb4b6","#b6a7d4","#9e8c62","#6e83c8", | |
"#01af64","#a71afd","#cfe589","#d4ccd1","#fd4109","#bf8f0e","#2f786e","#4ed1a5","#d8bb7d","#a54509","#6a9276", | |
"#a4777a","#fc12c9","#606f15","#3cc4d9","#f31c4e","#73616f","#f097c6","#fc8772","#92a6fe","#875b44","#699ab3", | |
"#94bc19","#7d5bf0","#d24dfe","#c85b74","#68ff57","#b62347","#994b91","#646b8c","#977ab4","#d694fd","#c4d5b5", | |
"#fdc4bd","#1cae05","#7bd972","#e9700a","#d08f5d","#8bb9e1","#fde945","#a29d98","#1682fb","#9ad9e0","#d6cafe", | |
"#8d8328","#b091a7","#647579","#1f8d11","#e7eafd","#b9660b","#a4a644","#fec24c","#b1168c","#188cc1","#7ab297", | |
"#4468ae","#c949a6") | |
} | |
scdata$color_active_ident <- color_pool[as.numeric(scdata@active.ident)] | |
########################## | |
# Coloring samples | |
########################### | |
remaining.colors <- color_pool[-c(1:length(unique(scdata@meta.data$color_active_ident)))] | |
if ("type"%in%colnames(scdata@meta.data)) # In that case we are in multisample experiment | |
scdata@meta.data[, "color_samples"] <- remaining.colors[as.numeric(as.factor(scdata$type))] | |
else | |
scdata@meta.data[, "color_samples"] <- remaining.colors[1] | |
return(scdata) | |
} | |
########################## | |
# Coloring active ident | |
########################### | |
scdata <- color_active_ident(scdata) | |
return(scdata) | |
} | |
color_active_ident <- function(scdata) { | |
if ("color_pool" %in% names(scdata@misc)){ | |
color_pool <- scdata@misc[['color_pool']] | |
} else { # THIS SHOULD BE REMOVE ONCE THE EXPERIMENT HAS BEEN UPDATED WITH THE NEW VERSION OF THE DATA-INGEST | |
color_pool <- c("#e377c2","#8c564b","#d62728","#2ca02c","#ff7f0e","#1f77b4","#f8e71c","#3957ff","#d3fe14", | |
"#c9080a","#fec7f8","#0b7b3e","#0bf0e9","#c203c8","#fd9b39","#888593","#906407","#98ba7f","#fe6794","#10b0ff", | |
"#ac7bff","#fee7c0","#964c63","#1da49c","#0ad811","#bbd9fd","#fe6cfe","#297192","#d1a09c","#78579e","#81ffad", | |
"#739400","#ca6949","#d9bf01","#646a58","#d5097e","#bb73a9","#ccf6e9","#9cb4b6","#b6a7d4","#9e8c62","#6e83c8", | |
"#01af64","#a71afd","#cfe589","#d4ccd1","#fd4109","#bf8f0e","#2f786e","#4ed1a5","#d8bb7d","#a54509","#6a9276", | |
"#a4777a","#fc12c9","#606f15","#3cc4d9","#f31c4e","#73616f","#f097c6","#fc8772","#92a6fe","#875b44","#699ab3", | |
"#94bc19","#7d5bf0","#d24dfe","#c85b74","#68ff57","#b62347","#994b91","#646b8c","#977ab4","#d694fd","#c4d5b5", | |
"#fdc4bd","#1cae05","#7bd972","#e9700a","#d08f5d","#8bb9e1","#fde945","#a29d98","#1682fb","#9ad9e0","#d6cafe", | |
"#8d8328","#b091a7","#647579","#1f8d11","#e7eafd","#b9660b","#a4a644","#fec24c","#b1168c","#188cc1","#7ab297", | |
"#4468ae","#c949a6") | |
} | |
scdata$color_active_ident <- color_pool[as.numeric(scdata@active.ident)] | |
########################## | |
# Coloring samples | |
########################### | |
remaining.colors <- color_pool[-c(1:length(unique(scdata@meta.data$color_active_ident)))] | |
if ("type"%in%colnames(scdata@meta.data)) # In that case we are in multisample experiment | |
scdata@meta.data[, "color_samples"] <- remaining.colors[as.numeric(as.factor(scdata$type))] | |
else | |
scdata@meta.data[, "color_samples"] <- remaining.colors[1] | |
return(scdata) | |
} | |
Possible refactor opportunity. Just a suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mm... Let me think a different refactoring since here we color two different things: sample and cluster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, I decide that this is a good solution by changing the function name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. One possibility is you could have some sort of generic color_metadata <- function(scdata, color_pool, column = c('color_samples', 'color_active_ident')) {...}
that does either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like Oliver created the same function here. Why don't you move it to e.g. utils.r
and call it as well?
Co-authored-by: Alex Pickering <[email protected]>
…-runner/glob-parent-5.1.2 Bump glob-parent from 5.1.1 to 5.1.2 in /local-runner
Background
Link to issue
https://biomage.atlassian.net/browse/BIOMAGE-682?atlOrigin=eyJpIjoiMTBiNGMwY2VkOTEzNDViMGFlOWMzYjAyNDA0ZWI0MzgiLCJwIjoiaiJ9
Link to staging deployment URL
Links to any Pull Requests related to this
Anything else the reviewers should know about the changes here
Before merging, changes related with Multisample support should be added (#13).
Changes
Code changes
Definition of DONE
Your changes will be ready for merging after each of the steps below have been completed:
Testing
To set up easy local testing with inframock, follow the instructions here: https://github.com/biomage-ltd/inframock
To deploy to the staging environment, follow the instructions here: https://github.com/biomage-ltd/biomage-utils
Documentation updates
Is all relevant documentation updated to reflect the proposed changes in this PR?
Approvers
Just before merging:
unstage
script in here: https://github.com/biomage-ltd/biomage-utils is executed. This script cleans up your deployment to stagingOptional