Skip to content

Commit

Permalink
edits_v3
Browse files Browse the repository at this point in the history
  • Loading branch information
kmholton committed Mar 13, 2018
1 parent e6774e8 commit 5b966f6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions ngs_genetics303qc_R.md
Expand Up @@ -105,18 +105,16 @@ library(biomaRt)
mart = useEnsembl("ENSEMBL_MART_ENSEMBL")
mart=useMart(biomart="ensembl", dataset="mmusculus_gene_ensembl")

#read in files, ending in run1.txt or whatever pattern you have
#can read in multiple files and convert

#read in file ending in .run1
files<-dir(pattern="*\\.run1.txt$")

#for loop, takes a while to run if lists are large

input<-files[1]
df<-read.table(input, header=T, sep="\t")
ensembl_ids<-df[,1]
input<-files[1] #file 1
df<-read.table(input, header=T, sep="\t") #read table
ensembl_ids<-df[,1] #get ensembl ids, first column
ids<-NULL
#get gene name and ensembl gene for each ensembl id
ids<-getBM(attributes=c("external_gene_name", "ensembl_gene_id"), filters="ensembl_gene_id", values=ensembl_ids, mart=mart)
#mrege together input with gene symbols, drops unannotated samples
output<-merge(ids, df, by.x="ensembl_gene_id", by.y="Row.names")
colnames(output)[1:2]<-c("Ensembl", "GeneID")
filename<-gsub(".txt", ".ids.txt", input)
Expand Down

0 comments on commit 5b966f6

Please sign in to comment.