nf-osi / nfportalutils

Utilities for NF Portal project and data management
https://nf-osi.github.io/nfportalutils/
MIT License
2 stars 2 forks source link

modify_annotations appears to no longer work. #164

Closed allaway closed 7 months ago

allaway commented 8 months ago

https://github.com/nf-osi/nfportalutils/blame/b3e25c334ae225648445a4d06b5922ea061452ec/R/convert_to_stringlist.R#L109

I haven't quite figured out why, though I suspect it is due to a change in how reticulate handles more complex/special python objects.

> synapse_id = "syn48391601"
> value = 'Mus musculus'
> key = 'species'
>   entity <- .syn$get_annotations(synapse_id) 
>   entity[key] <- value
>   .syn$set_annotations(entity)
Error in py_call_impl(callable, call_args$unnamed, call_args$named) : 
  TypeError: Expected a synapseclient.Annotations object
Run `reticulate::py_last_error()` for details.

What I have determined so far is that get_annotations should be returning an Annotations object, and presumably did at some point, but with several versions of synapseclient that I’ve tested (2.4-3.2), it appears to get coerced to an R list. Then, I can modify the key/value pair with out issues, like before.

But when I go to set annotations, entity is not converted back to an Annotations object (maybe just a regular dict instead?) so set_annotations fails.

Based on the lack of changes in nfportalutils to this function (aka it’s never changed) and the same behavior in a variety of synapseclient versions, I suspect reticulate got smarter and previously didn’t coerce the result of get_annotations where it now is.

If I use the higher-level synapser functions, it seems to work fine. I wonder if I should just switch this to use synapser?

> synapse_id = "syn48391601"
> value = 'Mus musculus'
> key = 'species'
>   annots <- synapser::synGetAnnotations(synapse_id) 
>   annots[key] <- value
>   synapser::synSetAnnotations(synapse_id, annots)
$Uuid
[1] "82cddffd-4927-4567-8206-6a70a638c477"

$assay
[1] "whole genome sequencing"

$species
[1] "Mus musculus"

$dataType
[1] "geneExpression"

$entityId
[1] "syn48391601"

$Component
[1] "GenomicsAssayTemplate"

$resourceType
[1] "experimentalData"
anngvu commented 7 months ago

For now, resolved with reticulate 1.28 installed.