Load the library and the data

# load the library

library(aKNNO)
library(data.table)

# download the data from GEO

data<-data.frame(fread("https://ftp.ncbi.nlm.nih.gov/geo/series/GSE92nnn/GSE92332/suppl/GSE92332_FAE_UMIcounts.txt.gz"),row.names=1)
data<-data[,grep("epi3",colnames(data))]

Process the data

# process the data using Seurat

obj<-CreateSeuratObject(counts=data,min.cells=3,min.features=200)
obj <- NormalizeData(obj) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA() %>% RunUMAP(dims=1:10)

Clustering based on aKNNO (the adaptive k-nearest neighbor graph with optimization)

# build the optimized adaptive k-nearest neighbor graph

obj<-FindNeighbors_aKNNO(obj,verbose = F)

# clustering on the optimized adaptive k-nearest neighbor graph

obj<-FindClusters(obj,graph.name="aKNN_O",verbose=F)

# visualization

DimPlot(obj,label=T,group.by="aKNN_O_res.0.8")+ggtitle("aKNNO")+NoLegend() -> p_aKNNO
DotPlot(obj,features=c("Krt19","Krt8","Top2a","Mki67","Muc2","Clca1","Lgr5","Ascl2","Fabp6","Apoa1","Gip","Chga","Chgb","Adh6a","Hck","Lrmp","Defa21","Defa22"))+theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) -> p_marker
p_aKNNO+p_marker

Comparision between aKNNO, KNN and KNN_high

# build the k-nearest neighbor graph using the same number of dims (1:50) and the method (rann) in the aKNNO 
obj<-FindNeighbors(obj,nn.method="rann",dims=1:50,verbose=F)

# clustering based on kNN at the default resolution of 0.8 and a high resolution of 2 
obj<-FindClusters(obj,verbose=F)
obj<-FindClusters(obj,resolution=2,verbose=F)

#visualization

DimPlot(obj,label=T,group.by="RNA_snn_res.0.8")+ggtitle("KNN")+NoLegend() -> p_KNN
DimPlot(obj,label=T,group.by="RNA_snn_res.2")+ggtitle("KNN_high")+NoLegend() -> p_KNN_high
p_aKNNO+p_KNN+p_KNN_high

Comparsion between the optimized delta and the default delta

# use the default delta (-0.5) to build the aKNN

obj<-FindNeighbors_aKNN(obj)

# clustering based on the aKNN 

obj<-FindClusters(obj,graph.name="aKNN",verbose=F)

#visualization


DimPlot(obj,label=T,group.by="aKNN_res.0.8")+ggtitle("aKNN")+NoLegend() -> p_aKNN
obj@misc$aKNNO_delta$plot_delta +ggtitle("delta optimization") -> p_delta
p_aKNNO+p_aKNN+p_delta