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
require(jsonlite) | |
require(curl) | |
#An example of the function input. | |
#Specify the project name, fields, and number of entries(size) to pull in each list | |
data <- list(list(project = "THCA-US", fields = c("id", "mutation", "chromosome", "start", "end"), size = 6659), | |
list(project = "THCA-SA", fields = c("id", "mutation", "chromosome", "start", "end"), size = 45126), | |
list(project = "LUSC-US", fields = c("id", "mutation", "chromosome", "start", "end"), size = 65063), | |
list(project = "LUSC-KR", fields = c("id", "mutation", "chromosome", "start", "end"), size = 64671), |
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
setwd("/Users/jakeconway/Desktop/icgcSampleData/Set 1") | |
fileList <- list.files() | |
set1 <- data.frame(); set2 <- data.frame(); set3 <- data.frame(); | |
for(file in fileList){ | |
temp_data <- read.table(file, header=TRUE, sep="\t") | |
temp_data$Mutation.ID <- as.character(temp_data$Mutation.ID) | |
set1 <- rbind(set1, temp_data) | |
rm(temp_data) | |
} | |
setwd("/Users/jakeconway/Desktop/icgcSampleData/Set 2") |
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
fromList <- function(input){ | |
elements <- unique(unlist(input)) | |
data <- unlist(lapply(input, function(x){x <- as.vector(match(elements, x))})) | |
data[is.na(data)] <- as.integer(0); data[data != 0] <- as.integer(1) | |
data <- data.frame(matrix(data, ncol = length(input), byrow = F)) | |
data <- data[which(rowSums(data) !=0), ] | |
names(data) <- names(input) | |
return(data) | |
} |
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
fromExpression <- function(vd){ | |
vd <- list(vd) | |
intersections <- lapply(vd, function(x) strsplit(names(unlist(x)), "&")) | |
intersections <- lapply(intersections[[1]], function(x) unlist(as.list(x))) | |
sets <- unique(unlist(intersections)) | |
data <- na.omit(data.frame(matrix(NA, ncol = length(sets)))) | |
names(data) <- sets | |
counts <- lapply(vd, function(x) unlist(x)) | |
names(counts[[1]]) <- NULL | |
counts[[1]] <- as.numeric(counts[[1]]) |
NewerOlder