Browse code

remove malfunctioning functions and reset to known working version

Shana White authored on 03/08/2018 17:11:46
Showing 10 changed files

... ...
@@ -2,7 +2,7 @@ Package: KEGGlincs
2 2
 Type: Package
3 3
 Title: Visualize all edges within a KEGG pathway and overlay LINCS data
4 4
         [option]
5
-Version: 1.7.1
5
+Version: 1.7.2
6 6
 Date: 2016-06-02
7 7
 Author: Shana White
8 8
 Maintainer: Shana White <vandersm@mail.uc.edu>, Mario Medvedovic <medvedm@ucmail.uc.edu>
... ...
@@ -2,7 +2,6 @@
2 2
 
3 3
 export(KEGG_lincs)
4 4
 export(KL_compare)
5
-export(add_KEGG_drugs)
6 5
 export(add_edge_data)
7 6
 export(cyto_vis)
8 7
 export(edge_mapping_info)
... ...
@@ -10,10 +9,8 @@ export(expand_KEGG_edges)
10 9
 export(expand_KEGG_mappings)
11 10
 export(generate_mappings)
12 11
 export(get_KGML)
13
-export(get_drug_table)
14 12
 export(get_fisher_info)
15 13
 export(get_graph_object)
16
-export(grab_KO_data)
17 14
 export(keggerize_edges)
18 15
 export(node_mapping_info)
19 16
 export(overlap_info)
... ...
@@ -25,7 +22,6 @@ import(AnnotationDbi)
25 22
 import(KEGGREST)
26 23
 import(KOdata)
27 24
 import(RJSONIO)
28
-import(XML)
29 25
 import(hgu133a.db)
30 26
 import(httr)
31 27
 import(methods)
32 28
deleted file mode 100644
... ...
@@ -1,62 +0,0 @@
1
-#' Add edges from disease/drug tables  
2
-#' @description Expand edge mappings to include drugs/drug targets
3
-#' for selected pathway
4
-#' @param edges A data.frame object obtained by using the function `expand_kegg_edges`
5
-#' @param KEGG_mappings A data.frame object obtained by using the function `expand_kegg_mappings`
6
-#' @param kegg_drug_table A data.frame object obtained by using the function `get_drug_table`
7
-#' @return A data.frame object similar to the expanded edges data frame but with additional
8
-#' edges representing known drugs/drug targets
9
-#' @export
10
-#' @examples
11
-
12
-#' end_res_KGML <- get_KGML("hsa01522")
13
-#' end_res_KEGG_mappings <- expand_KEGG_mappings(end_res_KGML)
14
-#' end_res_edges <- expand_KEGG_edges(end_res_KGML, end_res_KEGG_mappings)
15
-
16
-#' end_res_drugs <- get_drug_table("hsa01522")
17
-
18
-#' edges_plus_kdrug <- add_KEGG_drugs(end_res_edges, end_res_KEGG_mappings, end_res_drugs)
19
-
20
-add_KEGG_drugs <- function(edges, KEGG_mappings, kegg_drug_table){
21
-
22
-    edges$u_ID <- paste0(edges$entry1accession,":", edges$entry2accession)
23
-    kegg_drug_table$u_ID <- paste0(kegg_drug_table$drug_KEGG_ID,":", kegg_drug_table$gene_id)
24
-    
25
-    drugs_to_add <- subset(kegg_drug_table, !kegg_drug_table$u_ID %in% edges$u_ID)
26
-    edges_to_add <- data.frame(
27
-       "edgeID" = seq(from = (1 + max(edges$edgeID)), to = (nrow(drugs_to_add) + max(edges$edgeID))), 
28
-       "entry1accession" = drugs_to_add$drug_KEGG_ID,
29
-       "entry2accession" = drugs_to_add$gene_id,
30
-       "entry1" = NA,
31
-       "entry2" = NA,
32
-       "type" = "PCrel",
33
-       "subtype1" = "from_kegg_drug",
34
-       "value" = "--",
35
-       "subtype2" = NA,
36
-       "value2" = NA,
37
-       "specific_subtype" = "from_kegg_drug",
38
-       "is_direct" = 1,
39
-       "entry1type" = "compound",
40
-       "entry2type" = "gene",
41
-       "entry1symbol" = drugs_to_add$drug_name,
42
-       "entry2symbol" = drugs_to_add$gene_symbol,
43
-       "u_ID" = drugs_to_add$u_ID,
44
-       stringsAsFactors = FALSE
45
-    )
46
-    for (i in 1:nrow(edges_to_add)){
47
-        edges_to_add$entry2[i] <- KEGG_mappings$entryID[KEGG_mappings$entryACCESSION == 
48
-                                                            edges_to_add$entry2accession[i]][1]
49
-        if (edges_to_add$entry1accession[i] %in% KEGG_mappings$entryACCESSION){
50
-            edges_to_add$entry1[i] <- KEGG_mappings$entryID[KEGG_mappings$entryACCESSION == 
51
-                                                                edges_to_add$entry1accession[i]][1]
52
-        }
53
-    }
54
-    # Decide whether or not to map to all nodes of gene on map
55
-    # for (i in 1:nrow(edges_to_add)){
56
-    #     edges_to_add$entry2[i] <- list(KEGG_mappings$entryID[KEGG_mappings$entryACCESSION == edges_to_add$entry2accession[i]])
57
-    # }
58
-    all_edges <- rbind(edges[, -c(17)], edges_to_add[, -c(17)])
59
-
60
-}
61
-
62
-#load("/opt/raid10/genomics/shana/KEGG_drug_targets/via_cts_convert/compound_cgs_KEGG_filtered.rda")
63 0
deleted file mode 100644
... ...
@@ -1,81 +0,0 @@
1
-#' Import disease/drug tables from KEGG 
2
-#' @description Get data tables for disease/drug information associated with 
3
-#' selected pathway
4
-#' @param pathwayid A KEGG pathway ID of the form "hsa12345" 
5
-#' (only human pathways currently)
6
-#' @return A data.frame object with either disease or drug information
7
-#' @import XML
8
-#' @export
9
-#' @examples
10
-#' RA_drug_table <- get_drug_table("hsa05323")
11
-
12
-get_drug_table <- function(pathwayid){
13
-    
14
-    raw_tabs <- GET(paste0("http://www.kegg.jp/kegg-bin/pathway_dd_list?map=",
15
-                           pathwayid))
16
-    
17
-    dd_table <- XML::readHTMLTable(rawToChar(raw_tabs$content),which = 4,
18
-                                   stringsAsFactors = F)
19
-    if (nrow(dd_table) > 0){
20
-        d_table <- subset(dd_table, 
21
-                          substring(dd_table[,1], 1, 1) == "D")
22
-        if(nrow(d_table) == 0){
23
-            warning("No associated drug targets in selected pathway")
24
-            return()
25
-        }
26
-        names(d_table) <- c("drug_KEGG_ID", "drug_name", "gene_target")
27
-        d_table$gene_target <- strsplit(d_table$gene_target, " ")
28
-        
29
-        for(i in 1:nrow(d_table)){
30
-            l <- length(unlist(d_table$gene_target[i]))
31
-            d_table$drug_KEGG_ID[i] <- list(rep(d_table$drug_KEGG_ID[i], l))
32
-            d_table$drug_name[i] <- list(rep(d_table$drug_name[i], l))
33
-        }
34
-        
35
-        long_drug <- data.frame("drug_KEGG_ID" = unlist(d_table$drug_KEGG_ID), 
36
-                                "drug_name" = unlist(d_table$drug_name), 
37
-                                "gene_target" = unlist(d_table$gene_target),
38
-                                stringsAsFactors = FALSE)
39
-        for (i in 1:nrow(long_drug)){
40
-            long_drug$gene_id[i] <- strsplit(long_drug$gene_target[i], 
41
-                                             "\\(")[[1]][1]
42
-            long_drug$gene_symbol[i] <- regmatches(long_drug$gene_target[i], 
43
-                                                   gregexpr("(?<=\\().*?(?=\\))", 
44
-                                                            long_drug$gene_target[i], 
45
-                                                            perl=TRUE))[[1]]
46
-        }
47
-        drops <- "gene_target"
48
-        d_table <- long_drug[, names(long_drug) != drops]
49
-        
50
-        return(d_table)
51
-    }
52
-    else {
53
-        warning("No drugs or diseases associated with selected pathway")
54
-        return()
55
-    }
56
-}
57
-#' @rdname get_drug_table 
58
-get_disease_table <- function(pathwayid){
59
-    
60
-    url <- paste0("http://www.kegg.jp/kegg-bin/pathway_dd_list?map=",
61
-                  pathwayid)
62
-    dd_table <- data.frame(
63
-        XML::readHTMLTable(url, header = TRUE, which = 4, as.data.frame = FALSE), 
64
-        stringsAsFactors = FALSE)
65
-    if (nrow(dd_table) > 0){
66
-        d_table <- subset(dd_table, 
67
-                          substring(dd_table$Disease.drug, 1, 1) == "H")
68
-        if(nrow(d_table) == 0){
69
-            warning("No diseases associated with selected pathway")
70
-            return()
71
-        }
72
-        return(d_table)
73
-    }
74
-    else {
75
-        warning("No drugs or diseases associated with selected pathway")
76
-        return()
77
-    }
78
-}
79
-
80
-#' @examples
81
-#' RA_disease_table <- get_disease_table("hsa05323")
82 0
deleted file mode 100644
... ...
@@ -1,56 +0,0 @@
1
-#' Quickly access LINCS L1000 CGS's for set of perturbagens (KO's)
2
-#' @description Translate raw CGS data to easy-to-use format
3
-#' @export
4
-#' @param cell_line Choose from the set of cell lines: 
5
-#' (A375,A549,ASC,HA1E,HCC515,HEK293T,HEKTE,HEPG2,HT29,MCF7,NCIH716,NPC,PC3,
6
-#' SHSY5Y,SKL,SW480,VCAP)  
7
-#' @param data_type Choose from data types: (100_full, 100_bing, 50_lm)
8
-#' @param pert_time Choose from (6,24,48,96,120,144,168)
9
-#' @param pathway_nodes Keep NA unless certain set of perturbagens is designated
10
-#' @return A data frame with conveniently formatted LINCS L100 CGS
11
-#' @examples 
12
-#' MCF_LM_50 <- grab_KO_data("MCF7")
13
-#' MCF_BING_100 <- grab_KO_data("MCF7", data_type = "100_bing")
14
-#' 
15
-grab_KO_data <- function(cell_line, pert_time = 96, data_type = "50_lm", 
16
-                         pathway_nodes = NA){
17
-    data("KO_data", envir = environment())
18
-    KO_data <- get("KO_data")
19
-    keeps <- c(names(KO_data[1:3]), paste0("up",data_type), 
20
-               paste0("dn",data_type))    
21
-    suppressWarnings(    
22
-        if(is.na(pathway_nodes)){
23
-            KO_by_CT <- KO_data[KO_data$pert_time == pert_time & 
24
-                                    KO_data$cell_id == cell_line, keeps]
25
-        }
26
-    )
27
-    suppressWarnings(
28
-        if(!is.na(pathway_nodes)){
29
-            KO_by_CT <- KO_data[KO_data$pert_time == pert_time & 
30
-                                    KO_data$cell_id == cell_line &
31
-                                    KO_data$pert_desc %in% pathway_nodes, keeps]
32
-        }
33
-    )
34
-    names(KO_by_CT)[c(4,5)] <- c("up", "down")
35
-    KO_by_CT <- KO_by_CT[,c(2,4:5)]
36
-    data("conversion_key")
37
-    data("L1000_LM_genes")
38
-    
39
-    for (i in 1:nrow(KO_by_CT)){
40
-        
41
-        KO_by_CT$up_SYMBOL[i] <- 
42
-            list(conversion_key$pr_gene_symbol[
43
-                which(conversion_key$pr_id %in% 
44
-                unlist(strsplit(KO_by_CT$up[i], ";")))])
45
-        KO_by_CT$down_SYMBOL[i] <-
46
-            list(conversion_key$pr_gene_symbol[
47
-                which(conversion_key$pr_id %in% 
48
-                unlist(strsplit(KO_by_CT$down[i], ";")))])
49
-        KO_by_CT$up_count[i] <- length(unlist(KO_by_CT$up_SYMBOL[i]))
50
-        KO_by_CT$down_count[i] <- length(unlist(KO_by_CT$down_SYMBOL[i]))
51
-    }
52
-    KO_by_CT <- KO_by_CT[,c(1,4,5)]
53
-    names(KO_by_CT) <- c("knockout", "up", "down")
54
-    rownames(KO_by_CT) <- KO_by_CT$knockout
55
-    return(KO_by_CT)
56
-}
57 0
\ No newline at end of file
58 1
deleted file mode 100644
59 2
Binary files a/data/L1000_LM_genes.rda and /dev/null differ
60 3
deleted file mode 100644
61 4
Binary files a/data/conversion_key.rda and /dev/null differ
62 5
deleted file mode 100644
... ...
@@ -1,30 +0,0 @@
1
-% Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/add_KEGG_drugs.R
3
-\name{add_KEGG_drugs}
4
-\alias{add_KEGG_drugs}
5
-\title{Add edges from disease/drug tables}
6
-\usage{
7
-add_KEGG_drugs(edges, KEGG_mappings, kegg_drug_table)
8
-}
9
-\arguments{
10
-\item{edges}{A data.frame object obtained by using the function `expand_kegg_edges`}
11
-
12
-\item{KEGG_mappings}{A data.frame object obtained by using the function `expand_kegg_mappings`}
13
-
14
-\item{kegg_drug_table}{A data.frame object obtained by using the function `get_drug_table`}
15
-}
16
-\value{
17
-A data.frame object similar to the expanded edges data frame but with additional
18
-edges representing known drugs/drug targets
19
-}
20
-\description{
21
-Expand edge mappings to include drugs/drug targets
22
-for selected pathway
23
-}
24
-\examples{
25
-end_res_KGML <- get_KGML("hsa01522")
26
-end_res_KEGG_mappings <- expand_KEGG_mappings(end_res_KGML)
27
-end_res_edges <- expand_KEGG_edges(end_res_KGML, end_res_KEGG_mappings)
28
-end_res_drugs <- get_drug_table("hsa01522")
29
-edges_plus_kdrug <- add_KEGG_drugs(end_res_edges, end_res_KEGG_mappings, end_res_drugs)
30
-}
31 0
deleted file mode 100644
... ...
@@ -1,25 +0,0 @@
1
-% Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/get_dd_tables.R
3
-\name{get_drug_table}
4
-\alias{get_drug_table}
5
-\alias{get_disease_table}
6
-\title{Import disease/drug tables from KEGG}
7
-\usage{
8
-get_drug_table(pathwayid)
9
-
10
-get_disease_table(pathwayid)
11
-}
12
-\arguments{
13
-\item{pathwayid}{A KEGG pathway ID of the form "hsa12345" 
14
-(only human pathways currently)}
15
-}
16
-\value{
17
-A data.frame object with either disease or drug information
18
-}
19
-\description{
20
-Get data tables for disease/drug information associated with 
21
-selected pathway
22
-}
23
-\examples{
24
-RA_drug_table <- get_drug_table("hsa05323")
25
-}
26 0
deleted file mode 100644
... ...
@@ -1,31 +0,0 @@
1
-% Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/grab_KO_data.R
3
-\name{grab_KO_data}
4
-\alias{grab_KO_data}
5
-\title{Quickly access LINCS L1000 CGS's for set of perturbagens (KO's)}
6
-\usage{
7
-grab_KO_data(cell_line, pert_time = 96, data_type = "50_lm",
8
-  pathway_nodes = NA)
9
-}
10
-\arguments{
11
-\item{cell_line}{Choose from the set of cell lines: 
12
-(A375,A549,ASC,HA1E,HCC515,HEK293T,HEKTE,HEPG2,HT29,MCF7,NCIH716,NPC,PC3,
13
-SHSY5Y,SKL,SW480,VCAP)}
14
-
15
-\item{pert_time}{Choose from (6,24,48,96,120,144,168)}
16
-
17
-\item{data_type}{Choose from data types: (100_full, 100_bing, 50_lm)}
18
-
19
-\item{pathway_nodes}{Keep NA unless certain set of perturbagens is designated}
20
-}
21
-\value{
22
-A data frame with conveniently formatted LINCS L100 CGS
23
-}
24
-\description{
25
-Translate raw CGS data to easy-to-use format
26
-}
27
-\examples{
28
-MCF_LM_50 <- grab_KO_data("MCF7")
29
-MCF_BING_100 <- grab_KO_data("MCF7", data_type = "100_bing")
30
-
31
-}