please someone help me to run this code
0
0
Entering edit mode
Angel ▴ 40
@angel-7981
Last seen 7.0 years ago
Berlin

hello

I have a code too long to be pasted here. please assign some time to my problem kindly. long time i am trying to run this code but i am too new in R and never i could run this code. i have to get a result from this code but i could not find anyone around me to solve my problem...

i pasted my google derived address of my data and R script

https://drive.google.com/file/d/0BwOX04QQkaXTM1VMdHJCM3JjRHM/view?usp=sharing

https://drive.google.com/file/d/0BwOX04QQkaXTVDB1R0pHdFh4bHc/view?usp=sharing

https://drive.google.com/file/d/0BwOX04QQkaXTVDB1R0pHdFh4bHc/view?usp=sharing

https://drive.google.com/file/d/0BwOX04QQkaXTWDljSEFBVTAyRm8/view?usp=sharing

https://drive.google.com/file/d/0BwOX04QQkaXTdC1iOHlVY3JwMXM/view?usp=sharing

 

thank you so much for any help

software error R • 1.3k views
ADD COMMENT
1
Entering edit mode

Your link goes to my-drive

ADD REPLY
0
Entering edit mode

my data are in my derive

ADD REPLY
1
Entering edit mode

Sure, but when I click on the link I get into my own google drive...

ADD REPLY
0
Entering edit mode

sorry, you all right...I edited the links now all of my needed input files can be founds in mentioned links.

ADD REPLY
0
Entering edit mode

There's 200 lines of code there, and you give no indication of what's failing for you.  I think you should step through the code and then come back with a more specific explanation of what is causing you problems.  If you can chop your data down into a small reproducible example then you're far more likely to get some help.

ADD REPLY
0
Entering edit mode

thank you. i have a bed file from ribosome profiling and two txt files contain gene ids extreacted from sam files of ribosome profiling and mRNA profiling and and a file contains protein coding genes and their length in yeast. these mentioned files are my input for code. actually i can't get the reason of different errors by running some lines of my code. all i need that running this code on my data that i never reached since long time ago but my adviser tells i should do that as soon as possible.

for example by running the line 48 i got this error

Error in MATRS_new_1[, y] <- COUNTS_COL_new_1 : 
  number of items to replace is not a multiple of replacement length
 

>

ADD REPLY
1
Entering edit mode

It's highly unlikely that you will find somebody on this list who has the time to go through all your code and debug it for you. With an Open Source scripting language like R, most of the responsibility for making sure you are doing things correctly is on you. Because of that, it's critical that you read and interpret warning and error messages. So let's take a look. You got this message:

Error in MATRS_new_1[, y] <- COUNTS_COL_new_1 : 
  number of items to replace is not a multiple of replacement length

In that line of code you are trying to replace the yth column of MATRS_new_1 with an object called COUNTS_COL_new_1, and R says that the 'number of items to replace is not a multiple of replacement length'. I find this message to be pretty clear, but I suppose a naive user might not, especially because this has to do with something unexpected that R will do. So let's have an example

> z <- matrix(1:100, ncol = 10)
> z
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    1   11   21   31   41   51   61   71   81    91
 [2,]    2   12   22   32   42   52   62   72   82    92
 [3,]    3   13   23   33   43   53   63   73   83    93
 [4,]    4   14   24   34   44   54   64   74   84    94
 [5,]    5   15   25   35   45   55   65   75   85    95
 [6,]    6   16   26   36   46   56   66   76   86    96
 [7,]    7   17   27   37   47   57   67   77   87    97
 [8,]    8   18   28   38   48   58   68   78   88    98
 [9,]    9   19   29   39   49   59   69   79   89    99
[10,]   10   20   30   40   50   60   70   80   90   100
> z[,1] <- 1:2

> z
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    1   11   21   31   41   51   61   71   81    91
 [2,]    2   12   22   32   42   52   62   72   82    92
 [3,]    1   13   23   33   43   53   63   73   83    93
 [4,]    2   14   24   34   44   54   64   74   84    94
 [5,]    1   15   25   35   45   55   65   75   85    95
 [6,]    2   16   26   36   46   56   66   76   86    96
 [7,]    1   17   27   37   47   57   67   77   87    97
 [8,]    2   18   28   38   48   58   68   78   88    98
 [9,]    1   19   29   39   49   59   69   79   89    99
[10,]    2   20   30   40   50   60   70   80   90   100

That's pretty weird, right? I said to replace the first column of z with just two values, and R silently recycled those numbers to fill all 10 rows. This is something that often trips up new R users, as it isn't something you might expect. But let's say we try a different vector.

> z[,1] <- 1:3
Error in z[, 1] <- 1:3 :
  number of items to replace is not a multiple of replacement length
> z
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]    1   11   21   31   41   51   61   71   81    91
 [2,]    2   12   22   32   42   52   62   72   82    92
 [3,]    1   13   23   33   43   53   63   73   83    93
 [4,]    2   14   24   34   44   54   64   74   84    94
 [5,]    1   15   25   35   45   55   65   75   85    95
 [6,]    2   16   26   36   46   56   66   76   86    96
 [7,]    1   17   27   37   47   57   67   77   87    97
 [8,]    2   18   28   38   48   58   68   78   88    98
 [9,]    1   19   29   39   49   59   69   79   89    99
[10,]    2   20   30   40   50   60   70   80   90   100

So now R is getting all grumpy and refusing to play. But if you know that R will silently recycle values if the length of the values is a multiple of the thing you are replacing, then the error makes sense.

That's your one free primer on R's weirdness, because like I said, nobody has the time to help you debug all your code - that's on you. I should mention that googling 'R number of items to replace is not a multiple of replacement length' will bring up lots of posts that would have explained this to you, so going forward, that's a good way to figure things out.

ADD REPLY
0
Entering edit mode

thank you so much

ADD REPLY

Login before adding your answer.

Traffic: 452 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6