brendankelly / micropower

power estimation for microbiome studies analyzed with pairwise distances and PERMANOVA
35 stars 18 forks source link

Having trouble with calcOmega2 #2

Open willowsblade opened 9 years ago

willowsblade commented 9 years ago

Hi,

I'm new at this, so my apologies if I'm misusing the code. I'm having difficulty with several functions, and I suspect that it relates back to the groupNames function.

I have a UniFrac matrix from QIIME that contains data from 3 baseline and 3 follow-up samples. If I rename only the columns to the format g1s1, g2s2, g1s3, g2s4, g1s5, g1s6 groupNames works without a problem. But if I also rename the rows I run into the problem of duplicate rownames, which R does not allow. This also creates problems for any function that uses the command rownames(groupNames(mymatrix)). I am confused on the purpose of the groupNames function?

Thanks Diana

brendankelly commented 9 years ago

My apologies for your difficulty. The code, in general, is pretty clunky. I'm finishing up significant revisions, which I hope will make the workflow smoother. Hopefully will be able to post soon.

The groupNames function serves only to extract the "group name" from the sample label string. This just serves the purpose of downstream analysis that requires a grouping factor (i.e., PERMANOVA). To clarify how this function works, compare:

dimnames(calcUJstudy(simNull(c(5,5)))) dimnames(groupNames(calcUJstudy(simNull(c(5,5)))))

Not sure why you're running into the problem with rownames. A matrix can have duplicate rownames (as in the above example), but a data.frame can't. Is your imported distance matrix a data.frame rather than a matrix object in R?

willowsblade commented 9 years ago

I've tried with both a data frame and a matrix. I'm using RStudio, perhaps I'd do better to use just R for this. I managed to get other functions working using an awful piece of code involving substr().

Thank you for your quick reply.

brendankelly commented 9 years ago

Sorry again. The next update includes a vignette, which I hope will make the workflow more transparent (and will make working with prior study data easier).

Again, the key with groupNames is that the input is a matrix object with row and column names formatted as you see in the output of simNull. groupNames outputs the same matrix that was input, but with altered row and column names.

Brendan

On Wed, Jun 24, 2015 at 6:36 AM, willowsblade notifications@github.com wrote:

I've tried with both a data frame and a matrix. I'm using RStudio, perhaps I'd do better to use just R for this. I managed to get other functions working using an awful piece of code involving substr().

Thank you for your quick reply.

— Reply to this email directly or view it on GitHub https://github.com/brendankelly/micropower/issues/2#issuecomment-114819441 .