Skip to content

Instantly share code, notes, and snippets.

@idot
Created February 18, 2016 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idot/0be1b35f8db553dd85f9 to your computer and use it in GitHub Desktop.
Save idot/0be1b35f8db553dd85f9 to your computer and use it in GitHub Desktop.
converts chromosome names from Tair10 from ngsplot to numeric names
#!/usr/bin/env Rscript
#copy .metainfo and .chrnames.endsembl from orig tar.gz in subfolder and change
# chrnames, ID
#tar with tar -zcvf Tair10numeric.tar.gz Tair10numeric
convertRdata <- function(){
id <- "Tair10numeric"
dir.create(id, recursive=TRUE, show=FALSE )
dts <- dir(".", ".RData", full=TRUE)
for(d in dts){
print(d)
tableName <- load(d)
if(length(tableName) != 1){
stop("object has unexpected name or multiple tables loaded ", tableName)
}
df <- get(tableName)
df$chrom <- gsub("chr", "", df$chrom)
bn <- basename(d)
dt <- sub(".+?(\\..*)", "\\1", d)
iddt <- paste(id, dt, sep="")
outp <- paste(id,"/", iddt, sep="")
print(tableName)
print(length(df))
save(df, list=tableName, file=outp)
}
}
convertRdata()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment