I tried to follow your instructions but it did not work. I was playing
around with ',' and ')' but ... This is the version "the function I was
applying before":

> foo <- split (ahesc.ox.gr, seqnames(ahesc.ox.gr))
> chrMeans <-   seqapply(foo, function(x, y)
+                  {
+                         starts = seq(1, y, 300)
+                         ends = starts + 299
+                         mean(Views(start = starts, end = ends, subject =
Gcoverage[[x]]), na.rm = TRUE)
+                  }, names(chrLengths), chrLengths), use.names = FALSE)
Unexpected ',' in:
"                        mean(Views(start = starts, end = ends, subject =
Gcoverage[[x]]), na.rm = TRUE)
                 }, names(chrLengths), chrLengths),"


Thanks
Hermann





> chrLengths
     chr1      chr2      chr3      chr4      chr5      chr6      chr7
chr8
249250621 243199373 198022430 191154276 180915260 171115067 159138663
146364022
     chr9     chr10     chr11     chr12     chr13     chr14     chr15
chr16
141213431 135534747 135006516 133851895 115169878 107349540 102531392
90354753
    chr17     chr18     chr19     chr20     chr21     chr22      chrX
chrY
 81195210  78077248  59128983  63025520  48129895  51304566 155270560
59373566
> Gcoverage
SimpleRleList of length 24
$chr1
integer-Rle of length 249240530 with 240162 runs
  Lengths:  10143    210     87     23 225169 ...  18950    172    493
106
  Values :      0      1      0      1      0 ...      0      1      0
1

$chr10
integer-Rle of length 135524700 with 106386 runs
  Lengths: 95292    22 24357   696  1746 ...    55   798    34 50302   102
  Values :     0     1     0     1     0 ...     1     0     1     0     1

$chr11
integer-Rle of length 134945522 with 106676 runs
  Lengths: 175567    185     92     53  14911 ...    152    262    770
94
  Values :      0      1      0      1      0 ...      0      1      0
1

$chr12
integer-Rle of length 133813408 with 99614 runs
  Lengths: 66672   284  6973   159   895 ...    98  4299   165  1939    33
  Values :     0     1     0     1     0 ...     1     0     1     0     1

$chr13
integer-Rle of length 115109694 with 66106 runs
  Lengths: 19525839       16      774       72 ...      616     2458
105
  Values :        0        1        0        1 ...        1        0
1

...
<19 more elements
>

2013/1/20 Tim Triche, Jr. <tim.triche@gmail.com>

> foo <- split( GRanges, seqnames(GRanges) )
> byChr <- seqapply( foo, function you were applying before )
>
> --t
>
> On Jan 20, 2013, at 12:45 PM, Hermann Norpois <hnorpois@googlemail.com>
> wrote:
>
> > I am sorry, but I still have a problem. With your syntax I get a vector
> > that is going over all chromosomes. How do I get , for instance separate
> > vectors for each chromosomes?
> > Thanks
> >
> > 2013/1/17 Hermann Norpois <hnorpois@googlemail.com>
> >
> >> Hello,
> >>
> >> I would like to transform a GRange-object into something with density
> >> information related of bins, e.g. 1 bin=200bps. So it starts at
> poistion 1
> >> etc ...
> >> That means (according to testset.gr):
> >> bin 1    0
> >> bin 2    0
> >> ...
> >> bin 50  0
> >> bin 51    0.28        #10000-10200 => (200-144)/200
> >> bin 52    0.765        #10200-10400 => 153/200
> >> ...
> >> etc
> >> according to testset.gr (see below).
> >>
> >> How does it work? Is there a special function?
> >> Thanks
> >> Hermann
> >>
> >>
> >>> testset.gr
> >> GRanges with 20 ranges and 0 metadata columns:
> >>       seqnames           ranges strand
> >>          <Rle>        <IRanges>  <Rle>
> >>   [1]     chr1 [ 10144,  10353]      *
> >>   [2]     chr1 [ 10441,  10463]      *
> >>   [3]     chr1 [235633, 235766]      *
> >>   [4]     chr1 [237717, 237895]      *
> >>   [5]     chr1 [521444, 521624]      *
> >>   [6]     chr1 [540609, 540786]      *
> >>   [7]     chr1 [564495, 564672]      *
> >>   [8]     chr1 [565254, 566081]      *
> >>   [9]     chr1 [566537, 567272]      *
> >>   ...      ...              ...    ...
> >>  [12]     chr1 [569610, 570190]      *
> >>  [13]     chr1 [601057, 601196]      *
> >>  [14]     chr1 [713227, 713475]      *
> >>  [15]     chr1 [752533, 752578]      *
> >>  [16]     chr1 [752654, 752695]      *
> >>  [17]     chr1 [754405, 754539]      *
> >>  [18]     chr1 [755336, 755918]      *
> >>  [19]     chr1 [756027, 756458]      *
> >>  [20]     chr1 [756793, 756843]      *
> >>  ---
> >>  seqlengths:
> >>    chr1 chr10 chr11 chr12 chr13 chr14 ...  chr6  chr7  chr8  chr9  chrX
> >> chrY
> >>      NA    NA    NA    NA    NA    NA ...    NA    NA    NA    NA
> >> NA    NA
> >>> dput (testset.gr)
> >> new("GRanges"
> >>    , seqnames = new("Rle"
> >>    , values = structure(1L, .Label = c("chr1", "chr10", "chr11",
> "chr12",
> >> "chr13",
> >> "chr14", "chr15", "chr16", "chr17", "chr18", "chr19", "chr2",
> >> "chr20", "chr21", "chr22", "chr3", "chr4", "chr5", "chr6", "chr7",
> >> "chr8", "chr9", "chrX", "chrY"), class = "factor")
> >>    , lengths = 20L
> >>    , elementMetadata = NULL
> >>    , metadata = list()
> >> )
> >>    , ranges = new("IRanges"
> >>    , start = c(10144L, 10441L, 235633L, 237717L, 521444L, 540609L,
> >> 564495L,
> >> 565254L, 566537L, 567450L, 568038L, 569610L, 601057L, 713227L,
> >> 752533L, 752654L, 754405L, 755336L, 756027L, 756793L)
> >>    , width = c(210L, 23L, 134L, 179L, 181L, 178L, 178L, 828L, 736L,
> 453L,
> >> 545L, 581L, 140L, 249L, 46L, 42L, 135L, 583L, 432L, 51L)
> >>    , NAMES = NULL
> >>    , elementType = "integer"
> >>    , elementMetadata = NULL
> >>    , metadata = list()
> >> )
> >>    , strand = new("Rle"
> >>    , values = structure(3L, .Label = c("+", "-", "*"), class = "factor")
> >>    , lengths = 20L
> >>    , elementMetadata = NULL
> >>    , metadata = list()
> >> )
> >>    , elementMetadata = new("DataFrame"
> >>    , rownames = NULL
> >>    , nrows = 20L
> >>    , listData = structure(list(), .Names = character(0))
> >>    , elementType = "ANY"
> >>    , elementMetadata = NULL
> >>    , metadata = list()
> >> )
> >>    , seqinfo = new("Seqinfo"
> >>    , seqnames = c("chr1", "chr10", "chr11", "chr12", "chr13", "chr14",
> >> "chr15",
> >> "chr16", "chr17", "chr18", "chr19", "chr2", "chr20", "chr21",
> >> "chr22", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", "chr9",
> >> "chrX", "chrY")
> >>    , seqlengths = c(NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> >> NA_integer_,
> >> NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> >> NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> >> NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> >> NA_integer_, NA_integer_, NA_integer_, NA_integer_)
> >>    , is_circular = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
> >> NA, NA,
> >> NA, NA, NA, NA, NA, NA, NA, NA, NA)
> >>    , genome = c(NA_character_, NA_character_, NA_character_,
> >> NA_character_,
> >> NA_character_, NA_character_, NA_character_, NA_character_,
> NA_character_,
> >> NA_character_, NA_character_, NA_character_, NA_character_,
> NA_character_,
> >> NA_character_, NA_character_, NA_character_, NA_character_,
> NA_character_,
> >> NA_character_, NA_character_, NA_character_, NA_character_,
> NA_character_
> >> )
> >> )
> >>    , metadata = list()
> >> )
> >
> >    [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > Bioconductor mailing list
> > Bioconductor@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/bioconductor
> > Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>

	[[alternative HTML version deleted]]

