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,]
## R0 p0 q0
## Ptgfrn 0.2495856 0 0
## Hspa8 0.2538195 0 0
## Rps3a3 0.2587549 0 0
## Muc6 0.2820250 0 0
## Gm5575 0.2938021 0 0
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,]
## R0 p0 q0 R1 p1 q1
## Osbpl2 1.0082917 0.274 0.4717023 1.423183 0.003 0.2978788
## Nrxn3 0.9713071 0.017 0.0690252 1.771032 0.016 0.4839385
## Scn3b 0.8536292 0.000 0.0000000 1.810641 0.000 0.0000000
## Ptk2b 1.0106767 0.350 0.5453321 1.900330 0.053 0.5675272
## Foxj2 1.0020631 0.069 0.1919813 1.933829 0.061 0.5690185
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.