We have a list which contain sublists, and these sublists contain Seurat objects. In each object metadata we have a variable which we'd like group based on. We'd like to group these objects into a new list based on this variable. Any help on appending objects to a predefined list based on this variable will be appreciated.
To visualise it we have:
list
listA
object1@metadata$variable1["X"]
object2@metadata$variable1["Y"]
object3@metadata$variable1["Z"]
object4@metadata$variable1["X"]
object5@metadata$variable1["Y"]
listB
object1@metadata$variable1["X"]
object2@metadata$variable1["Y"]
object3@metadata$variable1["Y"]
listC
object1@metadata$variable1["X"]
object2@metadata$variable1["Y"]
object3@metadata$variable1["X"]
listD
object1@metadata$variable1["X"]
object2@metadata$variable1["X"]
object3@metadata$variable1["Z"]
object4@metadata$variable1["Z"]
and we want to append these objects to a new list based on variable1, i.e all the listA variable1["X"] objects together, listA variable1["Y"] objects together, etc.
We've tried to use pmatch to match the string of the metadata variable to the string in the predefined list.
Any other strategies are very much welcome.