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

stack_order='fixed' sorts alphabetically instead of using given order #32

Open
bas-stringer opened this issue Jun 27, 2023 · 3 comments

Comments

@bas-stringer
Copy link

See title.

Logo(df, stack_order='fixed') results in stacks wherein the glyphs appear in alphabetic order, rather than in the order of df.columns

@atareen
Copy link
Collaborator

atareen commented Jun 29, 2023

Thanks, I'll work on fixing this soon. Could you please provide a minimal example to reproduce this.

Ammar

@tjlundgren
Copy link

tjlundgren commented Sep 20, 2024

I also would like to see this work! Here's an example:
(edit: formatting)

amino_acids = ['A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V']

Sort amino acids in reverse alphabetical order

amino_acids_sorted = sorted(amino_acids, reverse=True)

Generate random integers between 1 and 20 for 3 rows

data = np.random.randint(1, 21, size=(3, len(amino_acids_sorted)))

Create DataFrame with columns in reverse alphabetical order

df = pd.DataFrame(data, columns=amino_acids_sorted)
print(df)
logomaker.Logo(df,stack_order='fixed')

@tjlundgren
Copy link

tjlundgren commented Sep 20, 2024

It looks like the columns are reordered to pandas default (alphabetical) when either
self.df = validate_matrix(...)
or
self.df = transform_matrix(...)
edit: my quick fix didn't work. Please disregard.

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

3 participants