qiime2 / q2-metadata

BSD 3-Clause "New" or "Revised" License
3 stars 17 forks source link

Show column types in tabulate #3

Closed ebolyen closed 6 years ago

ebolyen commented 7 years ago

QIIME 2 will begin to centralize the inferences it makes on the types for metadata categories, tabulate should show that information as well.

gregcaporaso commented 6 years ago

These should be displayed in the tabulate viz, and it would also be helpful if they were exportable (i.e., they were written to file as the #q2:types directive line, as they are when you call Metadata.save).

The complex headers datatables example is a good example of what we're going for here, and we may or may not want to group by type (i.e., use the colspan functionality) - whoever implements this should experiment with that.

To get this information into the table json in tabulate, you can create a pd.MultiIndex as follows:

    df = input.to_dataframe()
    df_columns = pd.MultiIndex.from_tuples(
        [(n, t.type) for n, t in input.columns.items()],
        names=['column header', 'type'])
    df.columns = df_columns
    df.reset_index(inplace=True)
thermokarst commented 6 years ago

@gregcaporaso, @jairideout, @antgonza: would you guys prefer to see the column types as a second header row (ignore the sorting glyphs, this is just a proof of concept):

screen shot 2018-01-26 at 1 17 50 pm

or inlined:

screen shot 2018-01-26 at 1 19 02 pm
jairideout commented 6 years ago

I like the first example (column types as a second header row) because it matches the Metadata file format more closely than the inlined version. Could you also add the #q2:types directive in the cell directly below the ID header?

antgonza commented 6 years ago

What about a combination of two? Two rows but just separated by a new line so the controls are in the same cell? This comes cause the values can be pretty large (thus making them in 2 rows makes sense) but also the number of rows can be large so trying to keep it in 1 might make sense. If not easy, just go with 2. Now, is the header static? In other words, does it stay visible when you scrolldown?

gregcaporaso commented 6 years ago

I like the first example with two rows.

thermokarst commented 6 years ago

Here it is as two separate rows, no formatting:

screen shot 2018-01-29 at 11 42 50 am

Here it is as one "row," but with linebreaks inside the cell:

screen shot 2018-01-29 at 11 43 04 am

Here is the linebreaks inside the cell again, but with some element styling:

screen shot 2018-01-29 at 11 54 21 am

Thoughts @jairideout @gregcaporaso @antgonza ?

@antgonza - I also made sure that the header is "fixed" as per your request.

antgonza commented 6 years ago

@thermokarst, that looks pretty cool, thanks! I vote 3 😃.

jairideout commented 6 years ago

Option 3 looks really nice :shipit:

gregcaporaso commented 6 years ago

I also like option 3.