{"id":20969901,"url":"https://github.com/jumphone/scc","last_synced_at":"2025-06-23T05:10:27.104Z","repository":{"id":122690711,"uuid":"182140921","full_name":"jumphone/SCC","owner":"jumphone","description":"Single-Cell Communication Toolkit","archived":false,"fork":false,"pushed_at":"2019-08-02T21:05:24.000Z","size":12326,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T08:15:03.500Z","etag":null,"topics":["single-cell-analysis","single-cell-rna-seq"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jumphone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-18T18:50:04.000Z","updated_at":"2019-08-02T21:05:25.000Z","dependencies_parsed_at":"2023-05-02T22:31:49.560Z","dependency_job_id":null,"html_url":"https://github.com/jumphone/SCC","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jumphone/SCC","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumphone%2FSCC","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumphone%2FSCC/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumphone%2FSCC/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumphone%2FSCC/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jumphone","download_url":"https://codeload.github.com/jumphone/SCC/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jumphone%2FSCC/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259353134,"owners_count":22844747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["single-cell-analysis","single-cell-rna-seq"],"created_at":"2024-11-19T03:53:28.210Z","updated_at":"2025-06-11T22:09:00.896Z","avatar_url":"https://github.com/jumphone.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://github.com/jumphone/Bioinformatics/raw/master/scRNAseq/try_20190424/src/SCC_LOGO.png\" width=\"200\"\u003e\n\n### Single-Cell Communication (SCC) Toolkit \n\nAuthor: Feng Zhang\n \n* New feature is only for Seurat3\n\n### Prepare:\n\n    R package: hash, Seurat, Rtsne\n\n\n### Usage:\n\n    library('Seurat')\n    library(dplyr)\n    library(Matrix)\n    \n    source('https://raw.githubusercontent.com/jumphone/SCC/master/SCC.R')\n    \n    pbmc=load('pbmc.RDS') # load Seurat Object\n    \n    \n    ORITAG=as.character(pbmc@active.ident)   \n    VEC=pbmc@reductions$umap@cell.embeddings\n    pbmc.data=as.matrix(pbmc@assays$RNA@scale.data)\n    \n    SAVE_DIR=\"./\"\n    \n    used_cell= colnames(pbmc) # Used cell names\n    \n    used_gene= VariableFeatures(pbmc) # Used gene names\n    \n    USEDC=which(colnames(pbmc.data) %in% used_cell)\n    USEDG=which(rownames(pbmc.data) %in% used_gene)\n    \n    pbmc.data=pbmc.data[USEDG,USEDC]\n    VEC=VEC[USEDC,]\n    ORITAG=ORITAG[USEDC]\n    \n    #########################################\n    \n    \n    \n    library('Rtsne')\n    T1=Rtsne(VEC,dims=1)\n    ONE=T1$Y  \n    saveRDS(ONE,file=paste0(SAVE_DIR,'/','ONE.RDS'))\n    \n    NUM=100\n    \n    OUT=getBIN(ONE,NUM=NUM)\n    BIN=OUT$BIN\n    BINTAG=OUT$TAG\n    saveRDS(BIN,file=paste0(SAVE_DIR,'/','BIN.RDS'))\n    saveRDS(BINTAG,file=paste0(SAVE_DIR,'/','BINTAG.RDS'))\n    \n    pbmc@meta.data$bin=rep(NA, ncol(pbmc))\n    pbmc@meta.data$bin[USEDC]=BINTAG\n    pdf(paste0(SAVE_DIR,'/','1ID.pdf'),width=12,height=10)\n    DimPlot(pbmc,group.by='bin',reduction.use='umap', label=T)\n    dev.off()\n    \n\u003cimg src=\"https://github.com/jumphone/SCC/blob/master/img/PLOT1.png\" width=\"300\"\u003e\n\n    LR=read.table('ReceptorLigand.txt.mouse',header=T,sep='\\t')\n    #https://github.com/jumphone/Bioinformatics/tree/master/scRNAseq/RecLig/\n    \n    EXP=pbmc.data\n    \n    MEAN=getMEAN(EXP, LR, NUM=NUM)\n    saveRDS(MEAN,file=paste0(SAVE_DIR,'/','MEAN.RDS'))\n        \n    PMAT=getPMAT(EXP, LR, BIN, MEAN)\n    saveRDS(PMAT,file=paste0(SAVE_DIR,'/','PMAT.RDS'))\n    \n    pdf(paste0(SAVE_DIR,'/','GCOR.pdf'),width=20,height=20)\n    OUT=getPmatHEAT(PMAT,SHOW=T)\n    dev.off()\n    \n\u003cimg src=\"https://github.com/jumphone/SCC/blob/master/img/PLOT2.png\" width=\"300\"\u003e    \n    \n    HEAT=OUT$HEAT\n    DIST=OUT$DIST\n    ORDER=HEAT$colInd\n    \n    pdf(paste0(SAVE_DIR,'/','2CLUST.pdf'),width=20,height=20)\n    CLUST=getCLUST(ORDER, DIST, CCUT=0.7, SHOW=T)\n    dev.off()\n    \n\u003cimg src=\"https://github.com/jumphone/SCC/blob/master/img/PLOT3.png\" width=\"300\"\u003e\n\n    MLR=getMLR(CLUST, LR, PMAT)\n    LR=MLR[,c(1:2)]\n\n    CMAT=getCMAT(EXP,LR,PMAT,BI=TRUE)\n    saveRDS(CMAT,file=paste0(SAVE_DIR,'/','CMAT.RDS'))\n    \n    pdf(paste0(SAVE_DIR,'/','3CMAT.pdf'),width=15,height=13)\n    library('gplots')\n    heatmap.2(log(CMAT+1,10),scale=c(\"none\"),dendrogram='both',Colv=T,Rowv=T,trace='none',\n      col=colorRampPalette(c('blue3','grey95','red3')) ,margins=c(10,15))\n    heatmap.2(CMAT,scale=c(\"none\"),dendrogram='none',Colv=F,Rowv=F,trace='none',\n      col=colorRampPalette(c('blue3','grey95','red3')) ,margins=c(10,15))\n    dev.off()\n\n\u003cimg src=\"https://github.com/jumphone/SCC/blob/master/img/PLOT4.png\" width=\"300\"\u003e\n\u003cimg src=\"https://github.com/jumphone/SCC/blob/master/img/PLOT5.png\" width=\"300\"\u003e\n\n\n    OUT=getPAIR(CMAT)\n    PAIR=OUT$PAIR\n    SCORE=OUT$SCORE\n    RANK=OUT$RANK\n    saveRDS(PAIR,file=paste0(SAVE_DIR,'/','PAIR.RDS'))\n    \n    pdf(paste0(SAVE_DIR,'/','4CPlot_TOP200.pdf'),width=12,height=10)\n    CPlot(VEC,PAIR[1:200,],BINTAG)\n    dev.off()\n\n\u003cimg src=\"https://github.com/jumphone/SCC/blob/master/img/PLOT6.png\" width=\"300\"\u003e\n    \n    \n    \n    NET=getNET(PAIR, BINTAG,ORITAG )\n    write.table(NET,file=paste0(SAVE_DIR,'/','NET.txt'),sep='\\t',row.names=F,col.names=T,quote=F)\n       \n    CN=getCN(NET)\n    pdf(paste0(SAVE_DIR,'/','5DPlot.pdf'),width=100,height=100)\n    DP=DPlot(NET, CN, COL=3)\n    dev.off()\n\n\u003cimg src=\"https://github.com/jumphone/SCC/blob/master/img/PLOT7.png\" width=\"300\"\u003e\n    \n    ADP=p.adjust(DP,method='fdr')\n    \n    IDP=ADP\n    IDP[which(IDP==0)]=min(IDP[which(IDP\u003e0)])/2\n     \n    DD=sort(-log(IDP,10),decreasing=T)\n    CC=rep('grey',length(DD))\n    CC[which(DD\u003e -log(0.05,10))]='red'\n    pdf(paste0(SAVE_DIR,'/','PVALUE.pdf'),width=100,height=100)\n    par(mar=c(20,5,5,5))\n    barplot(DD,las=2,ylab='-log10(adjusted p-value)',col=CC)\n    dev.off()\n       \n\u003cimg src=\"https://github.com/jumphone/SCC/blob/master/img/PLOT8.png\" width=\"300\"\u003e\n  \n    \n    \n    CNET=c()\n    CNETSCORE=c()\n    TMP=DD[which(CC=='red')]\n    i=1\n    while(i \u003c=length(TMP)){\n        this_source=unlist(strsplit(names(TMP)[i],split='_to_'))[1]\n        this_target=unlist(strsplit(names(TMP)[i],split='_to_'))[2]\n        CNET=cbind(CNET, c(this_source,this_target))\n        CNETSCORE=c(CNETSCORE, TMP[i])\n        \n        i=i+1}\n    \n    OUT=cbind(t(CNET),CNETSCORE)\n    colnames(OUT)=c('source','target','score_neg_log_adp')\n    write.table(OUT,file=paste0(SAVE_DIR,'/','CNET.txt'),quote=F,sep='\\t',row.names=F,col.names=T)\n    \n\n\n\n    #SIG_INDEX=which(DP\u003c0.05)    \n    SIG_INDEX=which(ADP\u003c0.05)\n    SIG_PAIR=names(SIG_INDEX)\n    TOP_NET=NET\n    #TOP_NET=getNET(PAIR[1:500,], BINTAG,ORITAG )\n    \n    pdf(paste0(SAVE_DIR,'/','6LPlot.pdf'),width=100,height=100)\n    OUT=c()\n    #OUT_TYPE=c()\n    RCN=trunc(sqrt(length(SIG_PAIR))+1)\n    par(mfrow=c(RCN,RCN))\n    i=1\n    while(i\u003c= length(SIG_PAIR) ){\n        this_pair=SIG_PAIR[i]\n        LT=unlist(strsplit(this_pair, \"_to_\"))[1]\n        RT=unlist(strsplit(this_pair, \"_to_\"))[2]\n        try({\n        LP=LPlot(LT, RT, TOP_NET, PMAT,LR, MAIN=paste0(as.character(SIG_INDEX[i]),' ',SIG_PAIR[i]),SEED=12345,PCUT=0.05)    \n        #########################\n        this_out_index=which(LP[,1]\u003e-log(0.05,10) \u0026 LP[,2]\u003e-log(0.05,10))\n        this_out=t(LP)[,c(this_out_index,this_out_index)]\n        \n        if(length(this_out_index)\u003e0){ \n            colnames(this_out)=paste0(SIG_PAIR[i],'_|_',colnames(this_out))\n            OUT=cbind(OUT,this_out)}\n        #########################\n        colnames(LP)=paste0(c('Lexp','Rexp'),'_',c(LT,RT))\n        write.table(LP,file=paste0(SAVE_DIR,'/',as.character(SIG_INDEX[i]),'.tsv'),row.names=T,col.names=T,sep='\\t',quote=F)\n        })\n        print(i)\n        i=i+1}\n    dev.off()\n    \n\u003cimg src=\"https://github.com/jumphone/SCC/blob/master/img/PLOT9.png\" width=\"300\"\u003e\n    \n       \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    \n    ############################################\n    OUT=t(OUT)\n    OUT=unique(cbind(OUT,rownames(OUT)))\n    \n    get_LT\u003c-function(X){\n        X=unlist(strsplit(X, \"_\\\\|_\"))[1]\n        X=unlist(strsplit(X, \"_to_\"))[1]\n        return(X)\n        }\n    get_RT\u003c-function(X){\n        X=unlist(strsplit(X, \"_\\\\|_\"))[1]\n        X=unlist(strsplit(X, \"_to_\"))[2]\n        return(X)\n        }\n        \n    OUT_LT=apply(matrix(OUT[,3],ncol=1),1,get_LT)\n    OUT_RT=apply(matrix(OUT[,3],ncol=1),1,get_RT)\n    \n    OUT=cbind(OUT,OUT_LT,OUT_RT)\n    \n \n    \n    \n    \n    \n    library(plotly)\n    \n    COL=rep('rgb(230,230,230)',nrow(OUT))\n    COL[which(OUT_LT %in% c('Tumor Cells'))]='green'\n    COL[which(OUT_RT %in% c('Tumor Cells'))]='blue'\n    p \u003c- plot_ly(type = 'scatter', mode = 'markers') %\u003e%\n    add_trace(\n    x = OUT[,2], \n    y = OUT[,1],\n    text = OUT[,3],\n    hoverinfo = 'text',\n    marker = list(color=COL),\n    showlegend = F\n    )\n    htmlwidgets::saveWidget(as_widget(p), paste0(SAVE_DIR,'/',\"TumorLR.html\"))\n    \n    library(plotly)\n    \n    COL=rep('rgb(230,230,230)',nrow(OUT))\n    COL[which(OUT_LT %in% c('Proliferating Cells'))]='green'\n    COL[which(OUT_RT %in% c('Proliferating Cells'))]='blue'\n    p \u003c- plot_ly(type = 'scatter', mode = 'markers') %\u003e%\n    add_trace(\n    x = OUT[,2], \n    y = OUT[,1],\n    text = OUT[,3],\n    hoverinfo = 'text',\n    marker = list(color=COL),\n    showlegend = F\n    )\n    htmlwidgets::saveWidget(as_widget(p), paste0(SAVE_DIR,'/',\"ProliferatingLR.html\"))\n    \n    \n    \n    \n\n\n    TAG=groupTAG(BINTAG,LT=\"LGroup\",RT='RGroup',LC=c(1,2,3),RC=c(4,5,6))\n    TMP=getNET(PAIR, BINTAG, TAG )\n    LPlot(LT='LGroup', RT='RGroup', TMP, PMAT,SEED=123)    \n   \n    \n\n    \n    \n    \n    \n    \n    \n    \n    \n    \n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumphone%2Fscc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjumphone%2Fscc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjumphone%2Fscc/lists"}