Skip to content

In R 2.14.1, what does wrong sign in 'by' argument mean?

6 messages · Richard M. Heiberger, bioinformatics, David L Carlson +2 more

#
Here is my code


    slidingwindowplotATGC = function(windowsize, inputseq) 
    {

    starts = seq(1, length(inputseq)-windowsize, by = windowsize)
    n = length(starts)
    chunkGs = numeric(n)
    chunkAs = numeric(n)
    chunkTs = numeric(n)
    chunkCs = numeric(n)
    for (i in 1:n) { 
        chunk = windowsize[starts[i]:(starts[i]+9999)]
        chunkG = sum("g" == chunk)/length(chunk)
        chunkA = sum("a" == chunk)/length(chunk)
        chunkT = sum("t" == chunk)/length(chunk)
        chunkC = sum("c" == chunk)/length(chunk)
	  chunkGs[i] = chunkG
        chunkAs[i] = chunkA
	  chunkTs[i] = chunkT
	  chunkCs[i] = chunkC
	}   
   
plot(starts,chunkGs,type="b",ylim=c(min(min(chunkAs),min(chunkTs),min(chunkCs),min(chunkGs)),max(max(chunkAs),max(chunkTs),max(chunkCs),max(chunkGs))),col
= "red")
    points(starts,chunkTs,col = "blue")
    points(starts,chunkAs,col = "green")
    points(starts,chunkCs)
}


Im getting the following error message,

    Error in seq.default(1, length(inputseq) - windowsize, by = windowsize)
: 
      wrong sign in 'by' argument


which I never got before when running codes of this sort, infact I re ran
old code that worked perfectly before, except this time Im getting this
error message which doesn't seem to make any sense at all! I need help with
this before I go completely insane... Maybe Im just bad at this program, but
it seems to me that it has a mind of its own... I was also getting an error
message before regarding the ylim function, stating that it needed to be a
finite value, which is what I was giving it? HELP!!!

--
View this message in context: http://r.789695.n4.nabble.com/In-R-2-14-1-what-does-wrong-sign-in-by-argument-mean-tp4407926p4407926.html
Sent from the R help mailing list archive at Nabble.com.
#
Don't delete the context of the message. If you are sure that windowsize is
positive, are you also sure that it is less than length(inputseq)?
Error in seq.default(1, -10, 1) : wrong sign in 'by' argument

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352


Date: Tue, 21 Feb 2012 11:43:15 -0800 (PST)
From: bioinformatics <uccstudent at live.ie>
To: r-help at r-project.org

Thats all well and good but the number im using is a positive so that
shouldn't be happening.

--

From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Richard M. Heiberger
Sent: Tuesday, February 21, 2012 1:36 PM
To: bioinformatics
Cc: r-help at r-project.org
Subject: Re: [R] In R 2.14.1, what does wrong sign in 'by' argument mean?
[1] 1 2 3 4
Error in seq.default(1, 4, -1) : wrong sign in 'by' argument

        
On Tue, Feb 21, 2012 at 1:53 PM, bioinformatics <uccstudent at live.ie> wrote:

            
plot(starts,chunkGs,type="b",ylim=c(min(min(chunkAs),min(chunkTs),min(chunkC
s),min(chunkGs)),max(max(chunkAs),max(chunkTs),max(chunkCs),max(chunkGs))),c
ol
with
error
http://r.789695.n4.nabble.com/In-R-2-14-1-what-does-wrong-sign-in-by-argumen
t-mean-tp4407926p4407926.html
http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting
-guide.html>
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
#
On Tue, Feb 21, 2012 at 10:53:44AM -0800, bioinformatics wrote:
Hi.

Try to set options(error=utils::recover) before the run. When
the error occurs, you can see the values of the variables
inside the function, where the error occured.

Hope this helps.

Petr Savicky.
#
Petr Savicky <savicky <at> cs.cas.cz> writes:
[deleting context -- sorry, but posting via Gmane and I have
a short comment to make, so if I don't delete stuff it will
complain ...]
'bioinformatics': it's considered appropriate to at least
mentioned that you posted this on Stack Overflow as well:
<http://tinyurl.com/86npzft> I and another commenter there
have spent a fair amount of effort already trying to help.
It would be better to address the comments there instead of
spreading effort across two different mailing lists.

  As is discussed there, part of the problem is confusion
over whether you're starting from a single string (i.e.
length(inputseq)==1 and nchar(inputseq) is a numeric vector
with length 1 and value >1) or a string of single characters
(i.e. length(inputseq)>1 and all(nchar(inputseq)==1)).  Beyond
that, and more critically, your 

    chunk = windowsize[starts[i]:(starts[i]+9999)]

doesn't make any sense if 'windowsize' is a single value.

In other words, it's a little hard to believe that this particular
code chunk ever did something sensible.

  Ben Bolker