Skip to content
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

Ordering of the timepoints #14

Open
Marius1311 opened this issue May 25, 2020 · 2 comments
Open

Ordering of the timepoints #14

Marius1311 opened this issue May 25, 2020 · 2 comments

Comments

@Marius1311
Copy link

Marius1311 commented May 25, 2020

In my AnnData object, I have a field adata.obs['day'], which is categorical, calling adata.obs['day'].cat.categories yields

Index(['0', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13',
       '15', '21', '36'],
      dtype='object')

So the values are strings in the right order. However, when I call Harmony using the scanpy interface, the timepoint connections are created using

    timepoints = adata.obs[tp].unique().tolist()
    timepoint_connections = pd.DataFrame(np.array([timepoints[:-1], timepoints[1:]]).T)

which permutes my timepoints to a random order. To keep the order, I need to change this to

    timepoints = list(adata.obs[tp].cat.categories)
    timepoint_connections = pd.DataFrame(np.array([timepoints[:-1], timepoints[1:]]).T)

It would be very important in my opinion to have some info in the docstring about the format that the time point annotation needs to have in order to results in the expected results. It would also be good to check the dtype of the passed .obs annotation and to create the timepoint connections accordingly, as this is really critical.

@awnimo
Copy link
Contributor

awnimo commented May 25, 2020

Hey @Marius1311
Thank you for reporting this issue. Will have this fixed in Scanpy. We will force data type as categorical for time points, and make the proper checkup and changes to the code, and docstring.

@Marius1311
Copy link
Author

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants