Open snystrom opened 3 years ago
I guess actually, just using I()
works:
df <- to_df(c(create_motif, create_motif(name = "motif2")))
df %>%
mutate(motif = I(ifelse(name == "motif2", motif_rc(edit_motif(motif)), edit_motif(motif))))
Or, of course, calling update_motif()
after an operation like this.
I can see how being able to do some things to motifs while they are still in the universalmotif_df
would be useful. But your suggestion in this case would leave the motif out of sync with the consensus column. I think there has to be a way to 'clean up' any changes which need propagating to the rest of the universalmotif_df
after applying the desired functions. Maybe there could be some kind of apply
-like function provided that would work well with pipes? But how many uses would this sort of functionality have beyond motif_rc()
? Maybe we could think of a workaround more specifically for motif_rc()
instead?
Yeah, that's a good point. Perhaps the solution is just to do update_motifs()
. I agree with the sentiment that it gets tedious to have to handle all these special cases, when in reality, the tools to solve the problem already exist. update_motifs()
and the print
out of sync warning do a good job there.
I'll do some more thinking about this. I don't think something like this is a very high priority feature.
I was just messing around with a set of motifs and I wanted to selectively RC one while using a universalmotif_df.
Of course, this doesn't work because of the
AsIs
class.So this got me thinking if there could be a way for folks to deprotect the motif for cases like this. Users doing this would know the operation is unsafe. Here's the silly implementation I came up with:
So the above becomes:
Not sure if this is the perfect solution. For instance, this won't keep the
AsIs
attribute after the mutate, so maybe a macro for wrapping the wholeifelse
operation to deprotect could work? I'll do some more thinking on this, but figured I'd post it now.