In grl.unlist, the final step is to merge the meta columns of the input GRangesList and the unlisted GRanges:
values(out) = BiocGenerics::cbind(values(grl)[out$grl.ix, , drop = FALSE], values(out))
If there is duplicated col names, it modifies the column name in out by appending .1 to it, while preserving colnames in values(grl). This is inconvenient because usually use case of the function would be to annotate a GRangesList in its unlisted form and then split back to listed form, after which the columns of the GRangesList and its elements column with the same name got swapped.
For example, both GRL and its elements have a column cn, then after gr = grl.unlist(grl); new.grl = split(gr, gr$grl.ix), the element in new.grl now have two columns cn and cn.1, however the cn.1 matches to the old element column cn, and the new cn matches to mcols(grl)$cn. This causes inconsistency.
I suggest simply swap the two argument in cbind, so that the element meta col names got preserved in the output.
In grl.unlist, the final step is to merge the meta columns of the input GRangesList and the unlisted GRanges:
values(out) = BiocGenerics::cbind(values(grl)[out$grl.ix, , drop = FALSE], values(out))If there is duplicated col names, it modifies the column name in
outby appending.1to it, while preserving colnames invalues(grl). This is inconvenient because usually use case of the function would be to annotate a GRangesList in its unlisted form and then split back to listed form, after which the columns of the GRangesList and its elements column with the same name got swapped.For example, both GRL and its elements have a column
cn, then aftergr = grl.unlist(grl); new.grl = split(gr, gr$grl.ix), the element innew.grlnow have two columnscnandcn.1, however thecn.1matches to the old element columncn, and the newcnmatches tomcols(grl)$cn. This causes inconsistency.I suggest simply swap the two argument in
cbind, so that the element meta col names got preserved in the output.