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

create "biom head" command to show the first n cols and rows of the table #639

Closed
josenavas opened this issue Aug 19, 2015 · 7 comments
Closed
Assignees

Comments

@josenavas
Copy link
Member

Sometimes you don't know what is on the table, so seeing the first rows/cols in the summarize-table output can really useful.

@antgonza
Copy link
Contributor

I suggest adding another parameter not changing the current summarize-table option.

@josenavas josenavas assigned josenavas and unassigned josenavas Aug 19, 2015
@josenavas
Copy link
Member Author

Make sure that the rows and columns that are shown actually include some data, if we choose the first X and Y it might not have any data, only 0.

@gregcaporaso
Copy link
Contributor

It might make sense to build this into the __repr__ method for the class (which would then be related to scikit-bio/scikit-bio#656).

@gregcaporaso
Copy link
Contributor

This could look something like this:

import numpy as np

def tsv_repr(t, n):
    obs_ids = t.ids(axis='observation')[:n]
    sam_ids = t.ids(axis='sample')[:n]
    data = np.zeros((n,n))
    for i, sam_id in enumerate(sam_ids):
        for j, obs_id in enumerate(obs_ids):
            data[i,j] = t.get_value_by_ids(obs_id, sam_id)
    print('\t' + '\t'.join(sam_ids))
    for obs_id, datum in zip(obs_ids, data):
        print('\t'.join([obs_id] + map(str,list(datum))))

tsv_repr(t, 5)

screenshot 2015-10-14 13 57 24

(but formatted nicer).

@gregcaporaso
Copy link
Contributor

... or maybe this would make more sense as a new biom head command?

@wasade
Copy link
Member

wasade commented Oct 14, 2015

I like head as its not a "summarization"
On Oct 14, 2015 15:19, "Greg Caporaso" notifications@github.com wrote:

... or maybe this would make more sense as a new biom head command?


Reply to this email directly or view it on GitHub
#639 (comment)
.

@wasade wasade self-assigned this Oct 15, 2015
@gregcaporaso gregcaporaso changed the title Show the first X cols and Y rows of the table in the summarize-table command create "biom head" command to show the first n cols and rows of the table Oct 19, 2015
@wasade wasade mentioned this issue Oct 19, 2015
@gregcaporaso
Copy link
Contributor

added in #669

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

4 participants