Created
February 27, 2018 19:13
-
-
Save SimonLarsen/a04706d140a3a596ad1f7fbcd6fcea4e to your computer and use it in GitHub Desktop.
Filter IID network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(data.table) | |
| library(org.Hs.eg.db) | |
| extract <- function(D, exp.only=FALSE, tissue=NULL, evidence=c("G","P")) { | |
| if(exp.only) { | |
| D <- D[grepl("exp", D$`evidence type`),] | |
| } | |
| if(!is.null(tissue)) { | |
| keep <- sapply(D[[tissue]], function(x) any(evidence %in% x)) | |
| D <- D[keep,] | |
| } | |
| D$entrez1 <- mapIds(org.Hs.eg.db, D$uniprot1, "ENTREZID", "UNIPROT") | |
| D$entrez2 <- mapIds(org.Hs.eg.db, D$uniprot2, "ENTREZID", "UNIPROT") | |
| D <- D[,c("entrez1","entrez2")] | |
| subset(D, !is.na(entrez1) & !is.na(entrez2)) | |
| } | |
| # Example: Extract experimentally validated lung-specific interactions. | |
| # D <- fread("iid.human.2017-04.txt", header=TRUE, sep="\t", quote="") | |
| # D.lung <- extract(D, exp.only=TRUE, tissue="lung") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment