Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@ on:
tags: [v*]
pull_request:
jobs:
format:
name: Runic formatting check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- run: julia -e 'using Pkg; Pkg.add("Runic")'
- run: julia -m Runic --check src/ test/
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
Expand All @@ -19,25 +30,23 @@ jobs:
- macOS-latest
arch:
- x64
include:
- version: 'nightly'
experimental: true
- version: '1'
experimental: false
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
continue-on-error: true
- uses: codecov/codecov-action@v4
continue-on-error: true # re-enable after v1.0
with:
file: lcov.info
7 changes: 7 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Re-enable status checks after v1.0 coverage baseline is established
coverage:
status:
project:
enabled: no
patch:
enabled: no
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Microbiome = "3bd8f0ae-a0f2-5238-a5af-e1b399a4940c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
Documenter = "1"
12 changes: 7 additions & 5 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ using Documenter, Microbiome, Microbiome.Dictionaries

makedocs(
sitename = "Microbiome.jl",
strict=:doctest,
warnonly = [:missing_docs, :cross_references],
doctest = false, # doctests disabled until outputs are updated for v1.0
pages = [
"Home" => "index.md",
"Samples and features" => "samples_features.md",
"Profiles and Communities" => "profiles.md",
"Diversity measures" => "diversity.md",
],
authors = "Kevin Bonham, PhD <kbonham@wellesley.edu",
authors = "Kevin Bonham, PhD <kbonham@wellesley.edu>",
format = Documenter.HTML(
prettyurls = get(ENV, "CI", nothing) == "true",
edit_link="main",
canonical="http://docs.ecojulia.org/BiobakeryUtils.jl/stable/")
)
edit_link = "main",
canonical = "https://docs.ecojulia.org/Microbiome.jl/stable/",
),
)

deploydocs(
repo = "github.com/EcoJulia/Microbiome.jl.git",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ CommunityProfile
samples
features
samplenames
**featurenames**
featurenames
commjoin
relativeabundance
relativeabundance!
Expand Down
1 change: 0 additions & 1 deletion docs/src/samples_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ Metabolite("other name", missing, missing, missing)

```@docs
MicrobiomeSample
metadata
```

```@docs
Expand Down
100 changes: 50 additions & 50 deletions src/Microbiome.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,68 @@ module Microbiome

# Samples and Features
export MicrobiomeSample,
Taxon,
GeneFunction,
Metabolite,
set!,
unset!,
insert!,
delete!,
name,
taxrank,
hasrank,
taxon,
hastaxon,
genefunction,
commonname,
masscharge,
retentiontime
Taxon,
GeneFunction,
Metabolite,
set!,
unset!,
insert!,
delete!,
name,
taxrank,
hasrank,
taxon,
hastaxon,
genefunction,
commonname,
masscharge,
retentiontime

# EcoBase Translations
export abundances,
nfeatures,
featurenames,
getfeature,
nsamples,
samplenames,
getsample,
AbstractFeature,
AbstractSample
# featureabundances,
# sampleabundances
nfeatures,
featurenames,
getfeature,
nsamples,
samplenames,
getsample,
AbstractFeature,
AbstractSample
# featureabundances,
# sampleabundances

# Profiles
export CommunityProfile,
featuretype,
features,
samples,
ranks,
rankfilter,
profiletype,
featuretotals,
sampletotals,
commjoin
featuretype,
features,
samples,
ranks,
rankfilter,
profiletype,
featuretotals,
sampletotals,
commjoin

# Abundances
export present,
prevalence,
relativeabundance!,
relativeabundance,
prevalence_filter
prevalence,
relativeabundance!,
relativeabundance,
prevalence_filter
# filterabund

# Diversity
export ginisimpson,
shannon,
ginisimpson!,
shannon!,
present,
prevalence,
braycurtis,
jaccard,
hellinger,
pcoa
shannon,
ginisimpson!,
shannon!,
present,
prevalence,
braycurtis,
jaccard,
hellinger,
pcoa

using Statistics
using SparseArrays
using EcoBase
Expand Down
16 changes: 8 additions & 8 deletions src/diversity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ When called on an `AbstractAbundanceTable`,
returns a 1 x nsamples matrix with 1 entry per sample.
See also [`shannon!`](@ref).
"""
function shannon(v::Union{AbstractVector{T}, AbstractSparseMatrix{T}}) where T<:Real
function shannon(v::Union{AbstractVector{T}, AbstractSparseMatrix{T}}) where {T <: Real}
total = sum(v)
logtotal = log(total)
# The iszero condition is necessary to prevent log(0)
Expand All @@ -29,7 +29,7 @@ If `overwrite=false` (the default), uses `insert!` to perform this operation,
so an error will be thrown if any sample already contains a `:shannon` entry.
Otherwise, uses `set!`.
"""
function shannon!(abt::AbstractAbundanceTable; overwrite=false)
function shannon!(abt::AbstractAbundanceTable; overwrite = false)
func! = overwrite ? set! : insert!
for s in samples(abt)
col = abt[:, s]
Expand All @@ -48,7 +48,7 @@ When called on an `AbstractAbundanceTable`,
returns a 1 x nsamples matrix with 1 entry per sample.
See also [`ginisimpson!`](@ref).
"""
function ginisimpson(v::Union{AbstractVector{T}, AbstractSparseMatrix{T}}) where T<:Real
function ginisimpson(v::Union{AbstractVector{T}, AbstractSparseMatrix{T}}) where {T <: Real}
total = sum(v)
return 1 - sum(x -> x^2, v) / (total^2)
end
Expand All @@ -66,7 +66,7 @@ If `overwrite=false` (the default), uses `insert!` to perform this operation,
so an error will be thrown if any sample already contains a `:ginisimpson` entry.
Otherwise, uses `set!`.
"""
function ginisimpson!(abt::AbstractAbundanceTable; overwrite=false)
function ginisimpson!(abt::AbstractAbundanceTable; overwrite = false)
func! = overwrite ? set! : insert!
for s in samples(abt)
col = abt[:, s]
Expand All @@ -81,26 +81,26 @@ end

Returns a pairwise Bray-Curtis dissimilarity matrix.
"""
braycurtis(abt::AbstractAbundanceTable) = pairwise(BrayCurtis(), collect(abundances(abt)), dims=2)
braycurtis(abt::AbstractAbundanceTable) = pairwise(BrayCurtis(), collect(abundances(abt)), dims = 2)

"""
jaccard(abt::AbstractAbundanceTable)

Returns a pairwise Jaccard distance matrix.
"""
jaccard(abt::AbstractAbundanceTable) = pairwise(Jaccard(), collect(abundances(abt)), dims=2)
jaccard(abt::AbstractAbundanceTable) = pairwise(Jaccard(), collect(abundances(abt)), dims = 2)

"""
hellinger(abt::AbstractAbundanceTable)

Returns a pairwise Hellinger distance matrix.
"""
hellinger(abt::AbstractAbundanceTable) = pairwise(HellingerDist(), collect(abundances(abt)), dims=2)
hellinger(abt::AbstractAbundanceTable) = pairwise(HellingerDist(), collect(abundances(abt)), dims = 2)

"""
pcoa(abt::AbstractAbundanceTable, f=braycurtis)

Returns eigenvectors from fitting `MDS` to a distance metric generated by `f`,
by default `braycurtis`.
"""
pcoa(abt::AbstractAbundanceTable, f=braycurtis) = fit(MDS, f(abt), distances = true)
pcoa(abt::AbstractAbundanceTable, f = braycurtis) = fit(MDS, f(abt), distances = true)
2 changes: 1 addition & 1 deletion src/ecobase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const samplenames = EcoBase.placenames
const getsample = EcoBase.placeoccurrences

abstract type AbstractFeature <: EcoBase.AbstractThings end
abstract type AbstractSample <: EcoBase.AbstractPlaces{Nothing} end
abstract type AbstractSample <: EcoBase.AbstractPlaces{Nothing} end
34 changes: 17 additions & 17 deletions src/features.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name(as::AbstractFeature) = as.name

const _ranks = (
domain = 0,
kingdom = 1,
phylum = 2,
class = 3,
order = 4,
family = 5,
genus = 6,
species = 7,
domain = 0,
kingdom = 1,
phylum = 2,
class = 3,
order = 4,
family = 5,
genus = 6,
species = 7,
subspecies = 8,
strain = 9
strain = 9,
)

const _shortranks = (
Expand All @@ -23,7 +23,7 @@ const _shortranks = (
g = :genus,
s = :species,
t = :subspecies,
u = missing
u = missing,
)

"""
Expand Down Expand Up @@ -51,16 +51,16 @@ See also [`taxon`](@ref Microbiome.taxon).
struct Taxon <: AbstractFeature
name::String
rank::Union{Missing, Symbol}

Taxon(s::AbstractString, ::Missing) = new(s, missing)
Taxon(s::AbstractString, rank::Symbol) = in(rank, keys(_ranks)) ?
new(s, rank) :
error("Invalid rank $rank, must be one of $(keys(_ranks))")
Taxon(s::AbstractString, rank::Symbol) = in(rank, keys(_ranks)) ?
new(s, rank) :
error("Invalid rank $rank, must be one of $(keys(_ranks))")
end

Taxon(n::AbstractString, rank::Int) = 0 <= rank <= 9 ?
Taxon(n, keys(_ranks)[rank+1]) :
error("Invalid rank $rank, must be one of $_ranks")
Taxon(n, keys(_ranks)[rank + 1]) :
error("Invalid rank $rank, must be one of $_ranks")
Taxon(n::AbstractString) = Taxon(n, missing)

function Base.String(t::Taxon)
Expand Down Expand Up @@ -239,7 +239,7 @@ Accessor function for the `rt` field of a [`Metabolite`](@ref).
retentiontime(m::Metabolite) = m.rt

@testset "Metabolites" begin
m1 = Metabolite("name", "common", 1., 1.)
m1 = Metabolite("name", "common", 1.0, 1.0)
@test name(m1) == "name"
@test commonname(m1) == "common"
@test masscharge(m1) == 1
Expand Down
Loading
Loading