Created
September 26, 2018 22:09
-
-
Save kieranrcampbell/cc265e9f7019a8c90f2a09d0145a68f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clusterMap <- function(sce1, sce2) { | |
clusters1 <- sort(unique(sce1$cluster)) # get unique clusters | |
clusters2 <- sort(unique(sce2$cluster)) | |
# Check this is gene (row) by cluster (cell) - if not needs transposed | |
cluster_means_1 <- sapply(clusters1, function(x) { | |
rowMeans(as.matrix(logcounts(sce1[,sce1$cluster == x])) | |
})) | |
cluster_means_2 <- sapply(clusters2, function(x) { | |
rowMeans(as.matrix(logcounts(sce2[,sce2$cluster == x])) | |
})) | |
# The cor function can take two matrices and return | |
# the correlations between their columns | |
cor(cluster_means_1, cluster_means_2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment