Skip to content

Instantly share code, notes, and snippets.

@ohofmann
Created February 15, 2012 16:03
Show Gist options
  • Save ohofmann/1836930 to your computer and use it in GitHub Desktop.
Save ohofmann/1836930 to your computer and use it in GitHub Desktop.
setwd('/Users/oho/Desktop/Methylation/')
load('probes.450k.rda')
data <- probes.450k
probes <- data$Probe_ID
length(probes)
bedMatrix <- matrix(nrow=length(probes), ncol=6)
for (i in 1:length(probes)) {
row <- data[i,]
coord <- row$coordinate
strand <- row$strand
if (strand == '+') {
start <- coord
end <- coord + nchar(row$sequence) - 1
}
else {
end <- coord + 1
start <- coord - nchar(row$sequence) + 2
}
name <- row$Probe_ID
chrom <- paste('chr', row$chr, sep='')
if (row$Design == 'II') {
score <- 2
}
else {
score <- 1
}
bedRow <- c(chrom, start, end, name, score, strand)
# print(paste(bedRow, sep=' '))
bedMatrix[i, ] <- bedRow
}
write.table(bedMatrix, file='450kprobes.bed', quote=F, row.names=F,
col.names=F, sep='\t')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment