Hello,
I have a dataset of algae species. Multiple sites and multiple sampling events with hundreds of species. Some species are only identified to genus (i.e., "Microcystis sp."), whereas others (sometimes in same sample event; sometimes not) are identified to species (i.e., "Microcystis speciesA", "Microcystis speciesB", etc.)
I am making the assumption that the Microcystis sp. are Microcystis speciesA, Microcystis speciesB, etc., and further assume that the relative abundance of speciesA and speciesB are similar throughout my dataset.
Therefore, I need to distribute the higher level parent (Microcystis sp.) to M. species A, and M. speciesB, dependent on the relative abundance of speciesA and speciesB. (This is known as "merge parents with children").
So, I need to:
- Determine relative proportion of M. speciesA, M. speciesB, etc.
- Multiply "species.cell.ml" of "Microcystis sp." by the relative proportions of speciesA, speciesB, etc.
- Add these values to speciesA, and speciesB (for samples collected the same day), otherwise, create new rows with speciesA and speciesB for that sample event.
- Delete the Microcystis sp. rows.
I have no idea how to do this, and am stuck.
I am hoping someone can help me!
Thanks!
I have included some of my data:
df2 <- data.frame(
stringsAsFactors = FALSE,
sampling.date = c("2019-10-22","2020-02-11","2020-02-11","2020-12-07",
"2020-05-27","2020-12-07","2021-03-15",
"2021-06-07","2022-02-22","2022-05-02",
"2019-10-22","2020-02-11","2020-05-27",
"2020-08-18","2020-12-07","2021-03-15","2021-06-07",
"2021-09-08","2022-02-22","2022-05-02"),
final.taxa.name = c("Microcystis ichthyoblabe","Microcystis ichthyoblabe",
"Microcystis smithii","Microcystis smithii",
"Microcystis sp.","Microcystis sp.",
"Microcystis sp.","Microcystis sp.",
"Microcystis sp.","Microcystis sp.",
"Microcystis wesenbergii","Microcystis wesenbergii",
"Microcystis wesenbergii","Microcystis wesenbergii",
"Microcystis wesenbergii","Microcystis wesenbergii",
"Microcystis wesenbergii",
"Microcystis wesenbergii","Microcystis wesenbergii",
"Microcystis wesenbergii"),
species.cells.ml = c(1044,
1290,200,10862,4500,37699,760,20617,20944,
320,720,6684,17546,1440,4595,10862,
47124,11488,2841,5640)
)
Created on 2023-08-02 with reprex v2.0.2