# From Mark Robinson, 31 October 2010 # Yep, pretty straightforward extension -- basically replace your 'windows' RangedData object with something containing the TSSs of interest. #library(rtracklayer) #session <- browserSession("ucsc") #q <- ucscTableQuery(session, "ensGene", range="hg18") #ensGene <- getTable(q) # need column names to match these #anno <- data.frame(chr=ensGene$chrom, strand=ensGene$strand, start=ensGene$txStart, end=ensGene$txEnd, name=ensGene$name) #head(anno) library(rtracklayer) session <- browserSession("UCSC") genome(session) <- "hg18" #trackNames(session) ## list the track names q <- ucscTableQuery(session, "knownGene") knownGene <- getTable(q) anno <- data.frame(chr=knownGene$chrom, strand=knownGene$strand, start=knownGene$txStart, end=knownGene$txEnd, name=knownGene$name) # You have other choices than "ensGene" and of course you can construct this from # sucking in a flat file from disk. 'rtracklayer' allows you to suck any table # from UCSC, which can be quite useful for other purposes too. # Then, all you do is replace your annotationBlocksCounts() call with annotationCounts() # ... the former uses start-end (like 1kb regions genome-wide), whereas the # latter will do the -1500 to +1000 calculation, obeying the strand information: #[...] fragSize<-200 counts <- annotationCounts(grl, anno, bpUp=1500, bpDown=1000, seqLen=fragSize, verbose=TRUE) head(counts) session <- browserSession("UCSC") genome(session) <- "hg18" trackNames(session) ## list the track names q <- ucscTableQuery(session, "knownGene") knownGene <- getTable(q) anno <- data.frame(chr=knownGene$chrom, strand=knownGene$strand, start=knownGene$txStart, end=knownGene$txEnd, name=knownGene$name) ## choose the Conservation track for a portion of mm9 chr1 query <- ucscTableQuery(session, "Conservation", GenomicRanges(57795963, 57815592, "chr12")) ## list the table names tableNames(query) ## get the phastCons30way track tableName(query) <- "phastCons30way" ## retrieve the track data track(query) ## get a data.frame summarizing the multiple alignment tableName(query) <- "multiz30waySummary" getTable(query) genome(session) <- "hg18" query <- ucscTableQuery(session, "snp129", names = c("rs10003974", "rs10087355", "rs10075230")) getTable(query) ## End(Not run)