First: Thanks for your input and ideas. I'm some steps further now:
I get peak calling-results (at least - I think so ;)).
I filtered the NA-lines with "alignedReads <- 
alignedReads[!is.na(position(alignedReads)) & !is.na(width(alignedReads))]"
(I wasn't sure if it is correct in this way, but printing the last line 
(tail) of my alignedReads-object doesn't show the NA-content anymore)
and added "options(error=recover)" - then I'm able to go through the 
whole script and print the peak-results (on command line).
But there are still errors -

/Fehler: Unerwartete(s) 'else' in "else"/

/Fehler in solveUserSEW0(start = start, end = end, width = width) :
   solving row 2: range cannot be determined from the supplied arguments 
(too many NAs)
Calls: processReads ... RangedData -> is -> IRanges -> solveUserSEW0 -> 
.Call/

---> Now it seems to by line 2..
/
Fehler: Unerwartete(s) '}' in "}"/

These are my peaks:

    /RangedData with 7944 rows and 1 value column across 1 space/
    /        space                 ranges   |     score/
    /<factor> <IRanges>   | <numeric>/
    /1           1       [ 54252,  54391]   | 0.6153529/
    /2           1       [ 54401,  54540]   | 0.6046273/
    /3           1       [150147, 150286]   | 0.5669448/
    /4           1       [150278, 150417]   | 0.5664235/
    /5           1       [346518, 346657]   | 0.5689336/
    /6           1       [346651, 346790]   | 0.5701618/
    /7           1       [411677, 411816]   | 0.5939812/
    /8           1       [411820, 411959]   | 0.5840657/
    /9           1       [530270, 530409]   | 0.6358737/
    /...       ...                    ... ...       .../
    /7936        1 [246900789, 246900928]   | 0.5669448/
    /7937        1 [246946659, 246946798]   | 0.5665375/
    /7938        1 [246946789, 246946928]   | 0.5650955/
    /7939        1 [247125296, 247125435]   | 0.5689336/
    /7940        1 [247125429, 247125568]   | 0.5701618/
    /7941        1 [247154735, 247154874]   | 0.5803391/
    /7942        1 [247154849, 247154988]   | 0.5904050/
    /7943        1 [247160188, 247160327]   | 0.5664235/
    /7944        1 [247160313, 247160452]   | 0.5669448/


And, at last, there is an error when exporting to bed:
/Fehler in as.vector(x, "character") :
   cannot coerce type 'closure' to vector of type 'character'
Calls: export.bed ... eval -> .Method -> as.character -> 
as.character.default/

Current code:

    args <- commandArgs()
    inputfile <- args[6]
    filename <- basename(inputfile)
    dir <- dirname(inputfile)

    outputfile <- args[10]

    type <- args[7]
    fragment_len <- as.numeric(args[8])
    sel_trim <- as.numeric(args[9])

    param <- ScanBamParam(simpleCigar=TRUE, reverseComplement=TRUE)
    alignedReads <- readAligned(dir, pattern=filename, type="BAM",
    param=param)

    alignedReads <- alignedReads[!is.na(position(alignedReads)) &
    !is.na(width(alignedReads))]

    if(type == 'p')
    {
             #Process the paired end reads, but discard those with
    length > 200
             reads_pair = processReads(alignedReads, type="paired",
    fragmentLen=fragment_len)

             #Process the reads, but now trim each read to 40bp around
    the dyad
             reads_trim = processReads(alignedReads, type="paired",
    fragmentLen=fragment_len, trim=sel_trim)
    }
    else
    {
             reads_pair = processReads(alignedReads, type="single",
    fragmentLen=fragment_len)
             reads_trim = processReads(alignedReads, type="single",
    fragmentLen=fragment_len, trim=sel_trim)
    }

    ###################################################
    ### code chunk number 4: coverage
    ###################################################
    #Calculate the coverage, directly in reads per million (r.p.m)
    cover_pair = coverage.rpm(reads_pair)
    cover_trim = coverage.rpm(reads_trim)

    ###################################################
    ### code chunk number 11: fft
    ###################################################
    htseq_raw = as.vector(cover_trim[[1]])
    htseq_fft = filterFFT(htseq_raw, pcKeepComp=0.02)

    ###################################################
    ### code chunk number 20: peaks2
    ###################################################
    peaks = peakDetection(htseq_fft, threshold="25%", score=TRUE, width=140)

    export.bed(peaks, score=NULL, name="Peaks", description=name,
    filepath=outputfile, splitByChrom=FALSE)



I'm still waiting for some shorter files (the ones I have cannot be 
imported with ShortRead) and will try to split the big files and try 
with less data.


On 09.11.2011 15:35, Oscar Flores wrote:
> El 09/11/2011 13:38, Stefanie Ververs escribió:
>> I got some smaller input file and will try to use it for NucleR, too. 
>> By now:
>
> The problem you have with nucleR is in the last part of processReads, 
> but seems it is not related a malfunction of nucleR but is due the 
> creation of a RangedData object with <NA> values. See:
>
> > RangedData(IRanges(NA))
> Error in solveUserSEW0(start = start, end = end, width = width) :
>   solving row 1: range cannot be determined from the supplied 
> arguments (too many NAs)
>
> I don't have experience working with BAM files, but could be that you 
> have an extra blank line at the end of your file and this creates a NA 
> record? Which is the output of:
>
> > alignedReads <- readAligned(dir, pattern=filename, type="BAM")
> > tail(alignedReads)
>
> Also, FYI, if you type "options(error=recover)" you will be able to 
> see the calling stack of the different functions when an error 
> ocurres. You can then look at the variables in that namespace (with 
> "ls") and take a look at them, maybe this could help...
>
>


	[[alternative HTML version deleted]]

