87 lines (86 with data), 2.6 kB
{
"cells": [
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"VAE_FCTAE_EM:\t0.0490555\tAE_FAETC_EM:\t0.04782872\tAE_FCTAE_EM:\t0.1351901\tDAE_FAETC_EM:\t0.05422764\tDAE_FCTAE_EM:\t0.06826419\tSVAE_FCTAE_EM:\t0.08426949\tMMDVAE_EM:\t0.07765315\t"
]
}
],
"source": [
"library(\"clusterCrit\")\n",
"data_names<-c('VAE_FCTAE_EM','AE_FAETC_EM', 'AE_FCTAE_EM', 'DAE_FAETC_EM', 'DAE_FCTAE_EM','SVAE_FCTAE_EM','MMDVAE_EM')\n",
"for(data_name in data_names){\n",
" cat(data_name)\n",
" cat(':\\t')\n",
" \n",
" number_cl=3\n",
" ind <- 0\n",
" JI_final <- matrix(data=NA, nrow=number_cl, ncol=1)\n",
" #cat(JI_final,\"\\n\")\n",
" # Read clusters imposed on simulated data \n",
" \n",
" cl <- as.matrix(read.table(\"../data/single-cell/celltype2.txt\", \n",
" sep=\"\\t\", header=FALSE))\n",
" cl2 <- as.matrix(as.numeric(cl[,2]))\n",
" rownames(cl2) <- cl[,1]\n",
" #cat(cl2)\n",
"\n",
" factor_path=paste(\"../data/single-cell/\",data_name,'.txt',sep='')\n",
" factorization=read.table(factor_path, sep=\" \",row.names=cl[,1], header=FALSE)\n",
"\n",
"\n",
" factors <- factorization\n",
"\n",
" # Clustering by Kmeans\n",
" JI_good <- numeric(0)\n",
" all_c_index <- numeric(0)\n",
" for (run in 1:100) {\n",
" kmeans.out <- kmeans(factors, centers=number_cl) \n",
" clust_iCluster <- kmeans.out$cluster\n",
"# cat(\"clust_iCluster:\",clust_iCluster,\"\\n\")\n",
" c_index <- numeric(0)\n",
" c_index <- c(c_index, intCriteria(as.matrix(factors),clust_iCluster, crit=c(\"C_index\"))$c_index)\n",
" all_c_index<-rbind(all_c_index,c_index)\n",
" \n",
" }\n",
" avg_c_index=apply(all_c_index,2,mean)\n",
" cat(avg_c_index)\n",
" cat('\\t')\n",
" \n",
" \n",
" }"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "R",
"language": "R",
"name": "ir"
},
"language_info": {
"codemirror_mode": "r",
"file_extension": ".r",
"mimetype": "text/x-r-source",
"name": "R",
"pygments_lexer": "r",
"version": "3.5.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}