library(RayleighSelection)
expression <- read.table(file = "https://www.dropbox.com/s/3ohj3evv3zwzrs9/filtered_normalized_counts_ordered.csv?dl=1", sep=",", header=TRUE, row.names=1, stringsAsFactors=FALSE) pca <- read.table("https://www.dropbox.com/s/onmnzlerl56ckq9/pca_50_ordered.csv?dl=1", sep=",", header=TRUE, row.names=1, stringsAsFactors = FALSE)
# A subsample of 100 cells is loaded below - reduce the number of cells to run faster # subsample_cells <- sample(nrow(pca), 100, replace=FALSE) # subsample_cells <- subsample_cells[order(subsample_cells)] # Use these cells if you want to directly reproduce the R0 and R1 scores below subsample_cells <- scan(file="https://www.dropbox.com/s/84z0poyz2vhqis8/tutorial_subsample.txt?dl=1", what=numeric())
subsample_pca <- pca[subsample_cells,] subsample_expression <- expression[,subsample_cells] # Take only genes that occur in >5% and <50% of cells subsample_expression <- subsample_expression[rowSums(subsample_expression != 0)>5,] subsample_expression <- subsample_expression[rowSums(subsample_expression != 0)<50,]
distance_matrix <- as.matrix(dist(subsample_pca, method="euclidean"))
gg <- vr_complex(distance_matrix, 28, clique = FALSE)
plot_skeleton(gg)
scoresR0 <- rayleigh_selection(gg, subsample_expression, num_perms = 1000, num_cores = 8, one_forms = FALSE) (scoresR0[order(scoresR0$R0),])[1:5,]
gg <- vr_complex(distance_matrix, 28, clique = TRUE)
plot_skeleton(gg)
This will take around 1 hour to run. Decrease the number of cells to run faster.
scores <- rayleigh_selection(gg, subsample_expression, num_perms = 1000, num_cores = 8, one_forms = TRUE) (scores[order(scores$R1, scores$R0),])[1:5,]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.