Skip to content

Commit

Permalink
Merge pull request #23 from kescobo/julia07fixes
Browse files Browse the repository at this point in the history
Move to julia 0.7
  • Loading branch information
kescobo authored Aug 9, 2018
2 parents c61dd0f + d72cd47 commit cb8bfb3
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 427 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ language: julia
os:
- linux
- osx
- windows
julia:
- 0.6
- 0.7
- nightly
notifications:
email: false
Expand All @@ -16,6 +17,7 @@ git:
matrix:
allow_failures:
- julia: nightly
- os: windows

## uncomment and modify the following lines to manually install system packages
#addons:
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# News for Microbiome.jl

## v0.3.0

Major changes:
- Dropped support for julia-0.6, moved on to julia-0.7
- Moved Plotting and BioBakery utilities out to separate packages to reduce dependencies
- These two new packages will be released shortly
- I'm keeping DataFrames dependency for now, though I'd like to move to IterableTables soonish (though constructors might be more sense in EcoBase)

## Older versions

I didn't have NEWS.md until v0.3. I doubt anyone cares, but I kinda tried to
keep track in release notes.
11 changes: 3 additions & 8 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
julia 0.6
SpatialEcology 0.3
julia 0.7-alpha
SpatialEcology 0.4
StatsBase
Reexport
RecipesBase
StatPlots
Distances
DataFrames
Clustering
Colors
CSVFiles
FileIO
MicroLogging
2 changes: 2 additions & 0 deletions docs/src/abundances.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ featurenames(abund2)

## Plotting

**NOTE: The following functions are not currently working - I've moved them to a new package to simplify dependencies. I'm leaving the docs for now as a reference - see `Microbiome.jl` versions 0.2.1 and below for working versions**

Some convenience plotting types are available using [`RecipesBase`](https://github.com/juliaplots/recipesbase.jl) and
[StatPlots](https://github.com/juliaplots/StatPlots.jl)

Expand Down
2 changes: 2 additions & 0 deletions docs/src/distances.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ variance(p, [1,2])

## Plotting

**NOTE: The following functions are not currently working - I've moved them to a new package to simplify dependencies. I'm leaving the docs for now as a reference - see `Microbiome.jl` versions 0.2.1 and below for working versions**

Some convenience plotting types are available using [`RecipesBase`](https://github.com/juliaplots/recipesbase.jl).

```@repl 2
Expand Down
26 changes: 5 additions & 21 deletions src/Microbiome.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,24 @@ export
optimalorder,
optimalorder!,
ginisimpson,
shannon,
## plotting
hclustplot,
annotationbar,
## utils
metaphlan_import,
panphlan_calcs,
bysample,
taxfilter,
taxfilter!,
qvalue!
shannon

using Reexport
@reexport using SpatialEcology
@reexport using Distances

using RecipesBase
using StatPlots
using LinearAlgebra
using Statistics
using StatsBase
using DataFrames
using FileIO
using CSVFiles
using MicroLogging
using Clustering

import SpatialEcology.@forward_func
import Clustering: Hclust, hclust
import SpatialEcology: @forward_func
import Base: getindex, setindex, length

include("ecotranslations.jl")
include("abundances.jl")
include("distances.jl")
include("leafordering.jl")
include("plotting.jl")
include("biobakery_utils.jl")


end # module Microbiome
15 changes: 8 additions & 7 deletions src/abundances.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Methods for absolute and relative abundances

abundancetable(df::DataFrame) = ComMatrix(
Matrix{Float64}(df[2:end]),
string.(df[1]),
String.(names(df[2:end])))
convert(Matrix{Float64}, df[2:end]),
string.(df[1]),
string.(names(df[2:end]))
)

abundancetable(table::AbstractArray{T,2},
site = ["sample_$x" for x in indices(table, 2)],
species = ["feature_$x" for x in indices(table, 1)]) where T<:Real =
ComMatrix(Float64.(table), species, site)
site = ["sample_$x" for x in axes(table, 2)],
species = ["feature_$x" for x in axes(table, 1)]
) where T<:Real = ComMatrix(Float64.(table), species, site)


"""
Expand All @@ -28,7 +29,7 @@ function filterabund(abun::AbstractComMatrix, n::Int=minimum(10, nfeatures(abun)

remainder = [sum(occurrences(abun)[srt[n+1:end], i]) for i in 1:size(abun, 2)]'
newabun = vcat(newabun, remainder)
newrows = cat(1, featurenames(abun)[srt[1:n]], ["other"])
newrows = cat(featurenames(abun)[srt[1:n]], ["other"], dims=1)

return abundancetable(newabun, samplenames(abun), newrows)
end
Expand Down
167 changes: 0 additions & 167 deletions src/biobakery_utils.jl

This file was deleted.

8 changes: 4 additions & 4 deletions src/distances.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function getdm(t::AbstractArray, distance::PreMetric)
end

function getdm(df::DataFrame, distance::PreMetric)
dm = pairwise(distance, Matrix(df[2:end]))
dm = pairwise(distance, convert(Matrix, df[2:end]))
for i in eachindex(dm); if isnan(dm[i]); dm[i] = 1; end; end
return DistanceMatrix(
dm,
Expand All @@ -59,7 +59,7 @@ function getrowdm(arr::AbstractArray, distance::PreMetric)
end

function getrowdm(df::DataFrame, distance::PreMetric)
m = Matrix(df[2:end])'
m = convert(Matrix, df[2:end])'
return DistanceMatrix(
pairwise(distance, m),
Vector(df[:,1]),
Expand Down Expand Up @@ -88,10 +88,10 @@ function pcoa(D::DistanceMatrix; correct_neg::Bool=false)
end

function sortedeig(M::Array{Float64,2})
f = eigfact(M)
f = eigen(M, scale=true, permute=true)
v = real.(f.values)
p = sortperm(v, rev = true)
return LinAlg.Eigen(v[p], real.(f.vectors[:,p]))
return LinearAlgebra.Eigen(v[p], real.(f.vectors[:,p]))
end


Expand Down
2 changes: 1 addition & 1 deletion src/leafordering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ For 2 multi-leaf branches, determine if one or two flips is required
4 = flip both
"""
function flip2(u::Int, m::Int, k::Int, w::Int, dm::Array{Float64,2})
indmin([dm[m,k], dm[u,k], dm[m,w], dm[u,w]])
argmin([dm[m,k], dm[u,k], dm[m,w], dm[u,w]])
end
Loading

0 comments on commit cb8bfb3

Please sign in to comment.