parametricTP() with extractIsotopeData and one baseline

52 views
Skip to first unread message

nadege....@hotmail.fr

unread,
Jun 27, 2018, 6:03:41 AM6/27/18
to tRophicPosition
Hi,
I have an issue with the calculation of the parametric version of TP with multiple species.
I only have one baseline, so that here is my code:

TP_List <- extractIsotopeData(TP_model, b1 = "Baseline1", b2 = NULL,
                             baselineColumn = "FG", consumersColumn = "Species",
                             groupsColumn = "Pond",
                             d13C = "D13C", d15N = "D15N")

This works nicely with the calculation of Bayesian TP using multiSpeciesTP.
Now I would like to compare these results with parametric estimates using parametricTP(). But because I only have one baseline, the function actually crashes on the first population and stops:
[1] "Parametric version of trophic position"
[1] "For consumer:  TMAR"
[1] "One baseline TP:  3.34"
[1] "Two baselines TP:  NaN NaN"
[1] "Full model TP. At the beginning:  NaN NaN"
Error in while (TP_p1 != TP_p2) { : missing value where TRUE/FALSE needed

Is there a way to make the function continue on other populations even with one baseline only?
Thank you for your help!
Nadège

nadege....@hotmail.fr

unread,
Jun 27, 2018, 6:08:04 AM6/27/18
to tRophicPosition
In fact I also have this issue when using credibilityIntervals(), as alpha is not computed with only one baseline, and replaced by "NA".

TP_models$df looks like:
  model   group      consumer    lower    upper   median     mode alpha.lower alpha.upper alpha.median  alpha.mode combined
1    1b      22          TMAR 2.511890 4.098319 3.269893 3.266149          NA          NA           NA         NA     --1b   


> credibilityIntervals(TP_models$df, x = "group", xlab ="Community")
Error: Discrete value supplied to continuous scale

Claudio Quezada R.

unread,
Jun 27, 2018, 9:26:40 AM6/27/18
to nadege....@hotmail.fr, tRophicPosition
Dear Nadège

Thank you for pointing this out. Indeed, this is an issue I have detected, but I haven't fixed (https://github.com/clquezada/tRophicPosition/issues/69). I will try to work in the parametric version of TP as soon as possible, and I will let you know when it's fixed.

In any case, when you have one baseline, there is no need to calculate the alpha parameter, because there is only one source of nitrogen, thus NA would be the same that 100 % (or 1) in that case.

Best wishes,

Claudio



--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposition-support@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.
To view this discussion on the web, visit https://groups.google.com/d/msgid/trophicposition-support/877b3e6c-5c95-4ea5-9362-21d68dccdd0d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Claudio Quezada R.

unread,
Jun 27, 2018, 10:24:24 AM6/27/18
to nadege....@hotmail.fr, tRophicPosition
Dear Nadège

I just committed a change in parametricTP(), that should fix your issue.

Please let me know if now it works.

Remember that you should install this version (0.7.6) from GitHub:

devtools::install_github("clquezada/tRophicPosition", build_vignettes = TRUE)
Cheers

Claudio

To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsubscr...@googlegroups.com.

nadege....@gmail.com

unread,
Jun 27, 2018, 12:27:00 PM6/27/18
to tRophicPosition
Thank you for answering that quickly! 

I installed the package from GitHub 
"This is tRophicPosition 0.7.6"

But I still get the same error with parametricTP()...

Nadège


To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposi...@googlegroups.com.

Claudio Quezada R.

unread,
Jun 27, 2018, 12:33:40 PM6/27/18
to nadege....@gmail.com, tRophicPosition
Could you send me your data? clquezada at harrodlab dot net if you don't want to post it publicly.

I checked here and it worked, but probably there is something I'm missing.

Cheers

Claudio

To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsubscr...@googlegroups.com.
To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposition-support@googlegroups.com.

nadege....@gmail.com

unread,
Jun 28, 2018, 6:27:40 AM6/28/18
to tRophicPosition
Hello,
It worked correctly after rebooting R! I put it in a loop with summary(), so that we get the parametric TP along with the population name:

for (Pond in TPList) {
  summary(Pond)
 parametricTP(Pond)
}

Getting TP values for multiple species in multiple populations in such a simple way is definitely comfortable! 
It would be even more convenient to store all results in a table with rows containing the group name, the species name and the TP value, just like the output of object$df when using multiSpeciesTP. I just don't figure out how to do that at the moment!
Thanks again,
Nadège
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

Claudio Quezada R.

unread,
Jun 28, 2018, 7:43:49 AM6/28/18
to nadege....@gmail.com, tRophicPosition
Hello Nadège

To store parametric TP data you just have to tweak your code. As each isotopeData class object has consumer and group as part of their attributes, you just have to extract that information, along with the calculation of one baseline parametric TP. Try this:

#First, we create empty lists
group <- list()
consumers <- list()
oneBaselineTP <- list()

#Then, we iterate through each pond in your TPList object
for (Pond in TPList) {
  summary(Pond)
  parametricTP(Pond)
 
  #Here we extract the information and append it to the lists created
  group <- rbind(group, attributes(Pond)$group)
  consumers <- rbind(consumers, attributes(Pond)$consumer)
  oneBaselineTP <- rbind(oneBaselineTP, parametricTP(Pond)[[1]])
}

#And then, we create a data frame

parametricTPList <- data.frame(group = group,
                               consumers =  consumers,
                               oneBaselineTP = oneBaselineTP)

Let me know if that works.

Cheers

Claudio

To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsubscr...@googlegroups.com.
To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsubscr...@googlegroups.com.

To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposition-support@googlegroups.com.

nadege....@gmail.com

unread,
Jun 28, 2018, 9:00:34 AM6/28/18
to tRophicPosition
It works perfectly!
I would even say it is really worth adding to a function or a help file.
Thanks!
Nadège
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

Claudio Quezada R.

unread,
Jun 28, 2018, 9:21:44 AM6/28/18
to Nuts Bél, tRophicPosition
Hello Nadège

I'm glad it works, you are very welcome. I will add it to a function, and probably write a vignette soon.

Remember to calculate trophic position by hand for a few species, to check that everything is right.

Cheers

Claudio

To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsubscr...@googlegroups.com.
To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsubscr...@googlegroups.com.

To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsubscr...@googlegroups.com.

To post to this group, send email to trophicposi...@googlegroups.com.
Visit this group at https://groups.google.com/group/trophicposition-support.

--
To download tRophicPosition package visit https://github.com/clquezada/tRophicPosition
---
You received this message because you are subscribed to the Google Groups "tRophicPosition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trophicposition-support+unsub...@googlegroups.com.
To post to this group, send email to trophicposition-support@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages