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

Indexing #87

Merged
merged 3 commits into from
Oct 10, 2021
Merged

Indexing #87

merged 3 commits into from
Oct 10, 2021

Conversation

kescobo
Copy link
Member

@kescobo kescobo commented Oct 10, 2021

This reworks indexing of CommunityProfiles. Previously, I had features and samples set as == if their names were the same. I thought this was a clever way to get indexing into the underlying AxisArray with sample/feature names for free, but might be causing problems with actually constructing them.

This PR removes the equality definitions, so things now have to have their underlying components ==, and then adds methods for indexing with Strings and Regexs. For stings, indexing is based on exact matches on the name, and for regexes, it returns all contains(samplename, regex).

examples:

julia> comm
CommunityProfile{Float64, Taxon, MicrobiomeSample} with 10 features in 5 samples

Feature names:
taxon1, taxon2, taxon3...taxon9, taxon10

Sample names:
sample1, sample2, sample3, sample4, sample5

julia> comm["taxon1", "sample1"]
CommunityProfile{Float64, Taxon, MicrobiomeSample} with 1 features in 1 samples

Feature names:
taxon1

Sample names:
sample1



julia> comm[r"taxon1", "sample1"]
CommunityProfile{Float64, Taxon, MicrobiomeSample} with 2 features in 1 samples

Feature names:
taxon1, taxon10

Sample names:
sample1



julia> comm[r"taxon1", r"sample[15]"]
CommunityProfile{Float64, Taxon, MicrobiomeSample} with 2 features in 2 samples

Feature names:
taxon1, taxon10

Sample names:
sample1, sample5

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

Successfully merging this pull request may close these issues.

None yet

1 participant