-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addCellMetadata performs an unexpected sort #853
Comments
Bit of a follow-up, prior to adding the metadata, I aggregated the expression matrix for my data as instructed in the Lung CosMx tutorial, and the columns of the matrix are already sorted: └──Spatial unit "�[34mcell�[39m"
├──Feature type "�[31mrna�[39m"
│ └──Expression data "�[36mraw�[39m" values:
│ An object of class exprObj : "raw"
│ spat_unit : "cell"
│ feat_type : "rna"
│ provenance: cell
│
│ contains:
│ 950 x 8557 sparse Matrix of class "dgCMatrix"
│
│ 6330403K07Rik . 1 . . . . . . . . 2 . . ......
│ Abca2 . . . . 1 . . . . . . . . ......
│ Abi1 . . . . 1 . . . . . 1 . 2 ......
│
│ ........suppressing 8544 columns and 944 rows in show(); maybe adjust options(max.print=, width=)
│
│ Zeb1 . . . . . . . . . . 1 . . ......
│ Zfyve16 . . . . . . . . . . 2 . . ......
│ Zwint . . 1 1 . . . . . . 11 . . ......
│
│ First four colnames:
│ fov011-cell_1 fov011-cell_10
│ fov011-cell_100 fov011-cell_101
│
└──Feature type "�[31mneg_probe�[39m"
└──Expression data "�[36mraw�[39m" values:
An object of class exprObj : "raw"
spat_unit : "cell"
feat_type : "neg_probe"
provenance: cell
contains:
10 x 8557 sparse Matrix of class "dgCMatrix"
NegPrb1 . . . . . . . . . . . . . ......
NegPrb10 . . . . . . . . . . . . . ......
NegPrb2 . . . . . . . . . . . . . ......
........suppressing 8544 columns and 4 rows in show(); maybe adjust options(max.print=, width=)
NegPrb7 . . . . . . . . . . . . . ......
NegPrb8 . . . . . . . . . . . . . ......
NegPrb9 . . . . . . . . . . . . . ......
First four colnames:
fov011-cell_1 fov011-cell_10
fov011-cell_100 fov011-cell_101 If I grab the cosmx mini dataset, the expression matrix columns there are not sorted, so it may be down to the |
Hi @rbutleriii Thank you for reporting and looking into this issue in detail! From what I have tracked down, the initial sorting happens after a call to These are likely causing the issue by propagating the ordering change into the metadata after A Assuming the above is the issue: The actual fix, could be implementing a check to match the expression row and col order to the expression information if they differ and/or adding a replacement method for Best, |
Hmm, it doesn't particularly make it problematic to have it sorted. I would almost always prefer to add metadata with a |
That is a good idea, thank you. I am pushing GiottoClass v0.1.3 and GiottoUtils v0.1.3 that should have the following fixes:
Importantly, this also means that the ordering of metadata may be different from the col/row ordering of the expression matrix (and the outputs from the Our current plan moving forward with In short: it is definitely preferred to add metadata with the |
Describe the Error
For some reason, with my CosMx data the
addCellMetadata
command triggers a sort of the cell rows in the giotto object (it doesn't do this with the starmap mini, vizium mini, or cosmx mini datasets).It looks like under the hood it is joined via a
data.table
merge, which has the default settingsort=T
, but usually follows the ordering inby.x
cell_ID
ifall.x=TRUE
.The reordering appears to be okay, as the giotto object also shifts the ordering of the column names in the expression matrix to match, but if someone is adding successive cell metadata without a cell_ID column as in method 1, the row ordering will now be different.
I can share the giotto object link to the compressed folder, but it is over 100MB with just two fovs.
...
To Reproduce
Expected behavior
Rows in the same order as with the cosmx mini dataset
System Information
The text was updated successfully, but these errors were encountered: