bramstone / qsip

R package to perform calculations on data produced from quantitative stable isotope probing (qSIP) experiments
6 stars 3 forks source link

Report an error: first argument has length > 1 #5

Open XMChao234 opened 2 months ago

XMChao234 commented 2 months ago

Dear Developers,

Following your example data and process, an error happened: "first argument has length > 1" when I run the code: "eaf <- calc_excess(wads,

In addition, an error happened: "Assigned label as the unamended or "light" treatment and light as the "heavy" treatment(s)." when use my own data to run the code: "ww <- wad_wide(wads,

Can you help to resolve these problems?

Thank you for your help!

bramstone commented 2 months ago

@XMChao234, the wad_wide() function is not returning an error, it is returning a message letting you know that it had to guess which of your isotope treatments is the "light" and which is the "labeled" treatment. I leave this up to the user to specify which treatment is which by assigning factor levels. If you do not code your iso_trt column as a factor, the function will do it for you – and it will assign factor levels alphabetically.

In this case, your treatment level "label" comes first in the alphabet and gets coded by the function as the unlabeled treatment. This appears to be opposite to what you want. I will update the package documentation and the output message to be more clear about this.

Here is code to fix the issue with the wad_wide code and to calculate the appropriate WAD values:

your_data$iso_trt <- factor(your_wads$iso_trt, levels = c("light", "label")

your_wads <- calc_wad(your_data, ...)
your_eaf <- calc_excess(your_wads, ...)

The issue with calc_excess was due to some internal coding with the data.table package. The problem is now fixed when I run the function on your example data. Please let me know how it runs on your end.

XMChao234 commented 2 months ago

Dear professor Stone,

Thank you very much for your reply and help.

best wishes,

Wencho Deng

Bram Stone @.***> 于2024年8月31日周六 02:30写道:

@XMChao234 https://github.com/XMChao234, the wad_wide() function is not returning an error, it is returning a message letting you know that it had to guess which of your isotope treatments is the "light" and which is the "labeled" treatment. I leave this up to the user to specify which treatment is which by assigning factor levels. If you do not code your iso_trt column as a factor, the function will do it for you – and it will assign factor levels alphabetically.

In this case, your treatment level "label" comes first in the alphabet and gets coded by the function as the unlabeled treatment. This appears to be opposite to what you want. I will update the package documentation and the output message to be more clear about this.

Here is code to fix the issue with the wad_wide code and to calculate the appropriate WAD values:

your_data$iso_trt <- factor(your_wads$iso_trt, levels = c("light", "label")

your_wads <- calc_wad(your_data, ...) your_eaf <- calc_excess(your_wads, ...)

The issue with calc_excess was due to some internal coding with the data.table package. The problem is now fixed when I run the function on your example data. Please let me know how it runs on your end.

— Reply to this email directly, view it on GitHub https://github.com/bramstone/qsip/issues/5#issuecomment-2322117074, or unsubscribe https://github.com/notifications/unsubscribe-auth/BK4PVTGGL2BKTH2N22GUCQTZUC223AVCNFSM6AAAAABNLSTTV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRSGEYTOMBXGQ . You are receiving this because you were mentioned.Message ID: @.***>