Skip to content

Instantly share code, notes, and snippets.

@ipurusho
Created February 17, 2015 20:59
Show Gist options
  • Save ipurusho/b47c9337318e43a6a8d9 to your computer and use it in GitHub Desktop.
Save ipurusho/b47c9337318e43a6a8d9 to your computer and use it in GitHub Desktop.
library(biomaRt)
library(stringr)
#######get counts #########
setwd("/path/to/count/directory")
data = list.files(pattern = 'htseq_counts.txt'); #detect count files based on file type
count_list = lapply(data,read.table,header=F,sep="\t",row.names=1) #read files in batch, save to list
counts<-do.call(cbind, count_list) #create count data frame
colnames(counts)<-data #set column names
colnames(counts)<-str_replace(colnames(counts),".htseq_counts.txt","")#remove filename extension
transcript_length<-nrow(counts)-5
transcript<-counts[1:transcript_length,] #removes last 5 rows (htseq mapping stat rows)
######get QC################
setwd("path/to/QC/directory")
QC_files = list.files(pattern = '.qcMetrics')
QC_list = lapply(QC_files,read.table,header=T,sep="\t")
QC_metrics<-do.call(rbind, QC_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment