0

I am trying to plot my biological data values against their unifrac distances in R. However, I got an error that the classes of data were different, and thats why I subsequently had errors with my plot, so I converted both to matrices, but am still getting errors when I run this:

unifrac.melt <- melt(as.matrix(unifrac.w))
unifrac.melt <- t(unifrac.melt)
fi.melt <- melt(as.matrix(data$fi)) #convert to dataframe
fi.melt <- t(fi.melt)
class(fiber.melt)

plot(fi.melt ~ unifrac.melt)

Error in xy.coords(x, y, xlabel, ylabel, log): 'x' and 'y' lengths differ

If anyone has suggestions please let me know!

How fi.melt appears:

row.names   V1          V2          V3  
1   Var1    1.00000     2.000000    3.000000
2   Var2    1.00000     1.000000    1.000000    
3   value   10.43247    8.837031    7.093047

How unifrac.melt appears:

row.names   V1          V2          V3  
1   Var1    30841102    49812105    26402102    
2   Var2    X30841102   X30841102   X30841102   
3   value   0.00000000  0.50184564  ....

The data appears as such, where it has 152 observations for 13 variables:

 row.names  BSequence   Sequence    Fi  FiCategory  Wg  WgCategory  V   VCategory   Fr  FrCategory  TVs An  Description
 1  30841102    CGATGCTGTAGATCGC    CTGTCTCTTATACACATCT 10.432465   Low 3.289473    Low 164.952225  Low 0.000000    None    222.952225  Yes NA
 2  49812105    TAATGAGCTAACCTCT    CTGTCTCTTATACACATCT 8.837031    Low 0.254120    Low 85.095326   Low 0.275000    Low 90.720326   No  NA
 3  26402102    TCCTGTTCTATCCTCT    CTGTCTCTTATACACATCT 7.093047    Low 2.619711    Low 96.203285   Low 0.000000    None    114.703285  No  NA

So, for reproducibility,

the original data comes as:

  envd <- matrix(rexp(2000, rate=.1), nrow=3, ncol=1976)

"fi" is the 3rd column of envd

unifrac.melt is like:

  unifracd <- matrix(rexp(30000, rate=.1), nrow= 3, ncol= 23104)
user4476006
  • 21
  • 1
  • 6
  • give an example data please so people can reproduce the error and will be able to help you –  Jul 18 '16 at 20:07
  • That's not enough information to make it reproducible. – joran Jul 18 '16 at 20:14
  • @joran what would you like? – user4476006 Jul 18 '16 at 20:15
  • 2
    @user4476006 use **dput** for example if your data called `mydata`then use dput(mydata) and paste it above in your question –  Jul 18 '16 at 20:15
  • Imagine you came to this question completely blind. Would you be able to copy & paste the code from the question such that your error is reproduced exactly as you see it? If not, there isn't enough information. – joran Jul 18 '16 at 20:19
  • Well, unifrac.melt is 3 observations of 23, 104 variables (distances) and fi.melt is 3 observations of 152 variables. That could just be made into blank data. I am not sure what to transform to make them comparable, since I am new to working with distances. – user4476006 Jul 18 '16 at 20:26
  • See [how to make a reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for tips on improving your question. If you make it easy to copy/paste into R, it will be easier to help you. – MrFlick Jul 18 '16 at 20:41
  • Added, please take a look! – user4476006 Jul 18 '16 at 21:11

0 Answers0