Skip to content

Instantly share code, notes, and snippets.

@ATpoint
Last active December 18, 2022 10:06
Show Gist options
  • Save ATpoint/1e870803df1c6faed92661bc603bea5f to your computer and use it in GitHub Desktop.
Save ATpoint/1e870803df1c6faed92661bc603bea5f to your computer and use it in GitHub Desktop.
# install.packages("data.table", "dplyr")
library(data.table)
library(dplyr)
parseProperly <- function(x){
x <- x[,-c(ncol(x)-1,ncol(x))]
x
}
# Read data drectly from GEO
m1 <- "https://ftp.ncbi.nlm.nih.gov/geo/series/GSE124nnn/GSE124167/suppl/GSE124167_FINAL_master_list_of_gene_counts_MIN.V4.txt.gz"
m2 <- "https://ftp.ncbi.nlm.nih.gov/geo/series/GSE124nnn/GSE124167/suppl/GSE124167_FINAL_master_list_of_gene_counts_MIN.sense.Pico.R.txt.gz"
m3 <- "https://ftp.ncbi.nlm.nih.gov/geo/series/GSE124nnn/GSE124167/suppl/GSE124167_FINAL_master_list_of_gene_counts_MIN.sense.Truseq.txt.gz"
method1 <- parseProperly(fread(m1, data.table=FALSE))
method2 <- parseProperly(fread(m2, data.table=FALSE))
method3 <- parseProperly(fread(m3, data.table=FALSE))
# Combine into a single table
counts <- Reduce(function(x, y) full_join(x, y, by="id"), list(method1, method2, method3))
# Replace NAs by zero
counts[is.na(counts)] <- 0
# Move "ids" to rownames to have a ure count matrix:
rownames(counts) <- counts$id
counts$id <- NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment