emmanuelparadis / ape

analysis of phylogenetics and evolution
http://ape-package.ird.fr/
GNU General Public License v2.0
52 stars 11 forks source link

allow del.gaps, del.rowgapsonly, del.colgapsonly to work on AAbin obj… #100

Closed KlausVigo closed 11 months ago

KlausVigo commented 11 months ago

Hello Emmanuel, small change to allow del.gaps, del.rowgapsonly and del.colgapsonly also working on AAbin objects. Regards, Klaus

emmanuelparadis commented 11 months ago

Hello Klaus, Sounds like a great idea! I had a quick look at the suggested additions. You propose

cl <- ifelse(inherits(x, "DNAbin"), "DNAbin", "AAbin")

and at then set the class of the returned object with class(x) <- cl. That would "loose" composite classes (e.g., c("haplotype", "DNAbin") as used in pegas). Why not have simply instead:

cl <- class(x)

Another thing is the internal function deleteGaps which could be:

deleteGaps <- function(x, gapcode) {
        i <- which(x == gapcode)
        if (length(i)) x[-i] else x
}

Then we'll have something like this somewhere in the main body:

gapcode <- ifelse(inherits(x, "DNAbin"), 4, 45)

and add the additional argument each time the internal function is called. What do you think? Cheers, Emmanuel

KlausVigo commented 11 months ago

Hi Emmanuel, all your your suggestion make total sense. I was just trying to fast subset some AA sequence and did some hacks without giving it too much thought. Cheers, Klaus

emmanuelparadis commented 11 months ago

I've pushed a new version here (5.7-1.5) that should do it. Cheers, Emmanuel