I am developing a QIIME2 plugin that uses R. The R script that is ultimately called needs to access the metadata file.
With many of the formats there is an option to provide a format that will return a string to a temporary directory containing the object (or it at least appears that way). With something like this I can then just read the file in R
example:
inputs={'table': 'phylogeny': Phylogeny[Unrooted])
Works well because in the function that is called I can pass as the object type in the parameters to the function as:
phylogeny: NewickFormat
Now this can be passed directly to an R command as a filepath
tree <- read.tree(tree.path)
How do I do this same thing with metadata? If for example I define the metadata type as:
metadata: Metadata
Now I have metadata object in python that I need to be able to get into R somehow. I could write this out to tsv and read it back in:
metadata.to_dataframe().to_csv(filepath)
Then in R I can read the table:
read.csv(filepath)
But this really seems like a round-a-about way to do it.
Alternatively I could call str
on the metadata object and then pass that to R:
read.csv(text='a\tb\tc\n1\t2\t3\n4\t5\t6')
But I have no idea what the delimiter is, it appears to be different numbers of spaces.
Any suggestions?
Thank you for your help!