Description Usage Arguments Details References Examples
View source: R/6.2.2_ISS_cluster_spatial.R
ISS spatial clustering by Markov random field with extended spatial parameters EM procedure. This function is incomplete and needs further development to work properly. See details.
1 2 | ISS_cluster_spatial(data, neighbor.points = 4,
spatial.info = "phisical")
|
data |
Input data in class MolDiaISS. Output of readISS. |
neighbor.points |
Number for neighbouring points. Default is 4. |
spatial.info |
Default is "phisical". Other value is "genetic". |
This function has build on the work on the article Pettit, J at el (2014). Current function "ISS_cluster_spatial" will only create 2 input for the actual algorithm veloped by Pettit, J at el (2014). After ruiing the function one has to run the actual algorithm for spatial clustering. See example for application.
Pettit, J., Tomer, R., Achim, K., Richardson, S., Azizi, L., & Marioni, J. (2014). Identifying Cell Types from Spatially Referenced Single-Cell Expression Datasets. PLoS Computational Biology, 10(9). doi:10.1371/journal.pcbi.1003824
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | ## Reading data
ex_data <- readISS(file = system.file("extdata", "Hypocampus_left.csv", package="MolDia"),
cellid = "CellId", centX = "centroid_x", centY = "centroid_y")
myres <- ISS_cluster_spatial(ex_data, neighbor.points = 4)
####################### Manual process to wun the algorithm
## Set working dirctory
mwd <- "c:/MRF"
## Save required data in working directory
main_data <- myres[[1]]
write.table(main_data, file = paste0(mwd,"/mdata.txt"),
col.names = FALSE, row.names = FALSE, quote = FALSE, sep = "\t")
neig_data <- myres[[2]]
write.table(neig_data, file = paste0(mwd,"/neig.txt"),
col.names = FALSE, row.names = FALSE, quote = FALSE,sep = "\t")
## For detail about the parameter and Download windows binary: https://github.com/jbogp/MRF_Platynereis_2014
## Save the windows binary in the current working directory. Make sure the exe file has the administrator privilege
win_exe <- paste0(mwd,"/EM.exe")
## Result folder name
res_fold <- "myResultFolder"
## Parameter set up
param1 <- paste0(mwd,"/mdata.txt")
param2 <- paste0(mwd,"/neig.txt")
param3 <- "rand"
param4 <- 0
param5 <- 20
param6 <- paste0(mwd,"/",res_fold)
param7 <- "myResultFile"
param8 <- 20
## Run the function in windows CMD
mycmd <- paste(win_exe, param1, param2, param3, param4, param5, param6, param7, param8)
res <- system(mycmd, intern = FALSE,invisible = FALSE)
## Read resulted cluster data data and convet it accordingly
cell_clust <- read.csv(paste0(mwd,"/",res_fold,"/myResultFile.csv"), header = F)
cell_clust <- as.factor(cell_clust$V1)
names(cell_clust) <- rownames(ex_data@data)
## Insert cluster information into main data object
ex_data@cluster <- cell_clust
## Map cluster data
pp<- RCA_map(ex_data, what = "cluster"
## Plot Spatial clustering
ex_data <- ISS_preprocess(ex_data)
ex_data <- ISS_tsne(ex_data)
ex_data <- ISS_marker(ex_data)
ISS_map(ex_data, what = "cell", main = "All cells")
ISS_map(ex_data, what = "cluster", main = "Spatial cluster: phisical distance", label.topgene = NULL)
ISS_map(ex_data, what = "tsne", main = "Spatial in tsne: phisical distance", label.topgene = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.