Bonjour,
Est il possible à partir d'une variable au format genpop (adegenet) d'en soustraire certaine population par un critère sur le nom et en refaire une autre variable au format genpop ?
Merci
Modérateur : Groupe des modérateurs
Code : Tout sélectionner
toto <- seppop(data)
Code : Tout sélectionner
popI <- toto[c(Pop1,Pop2)]
Code : Tout sélectionner
poppool <- repool(popI)
Code : Tout sélectionner
pop= c("nom1","nom2")
test = seppop(data,pop)
Code : Tout sélectionner
test1 = repool(test)
Code : Tout sélectionner
R version 3.1.0 (2014-04-10) -- "Spring Dance"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.
R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.
Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.
"),"pop"])) as.factor(as.character(colortab[which(colortab$PlantColor== "gold
Erreur dans is.factor(x) : objet 'colortab' introuvable
> source("preambule.r")
Le chargement a nécessité le package : ade4
==========================
adegenet 1.4-2 is loaded
==========================
- to start, type '?adegenet'
- to browse adegenet website, type 'adegenetWeb()'
- to post questions/comments: adegenet-forum@lists.r-forge.r-project.org
Le chargement a nécessité le package : combinat
Attachement du package : ‘combinat’
L'objet suivant est masqué from ‘package:utils’:
combn
Le chargement a nécessité le package : gdata
gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
Attachement du package : ‘gdata’
L'objet suivant est masqué from ‘package:stats’:
nobs
L'objet suivant est masqué from ‘package:utils’:
object.size
Le chargement a nécessité le package : gtools
Le chargement a nécessité le package : MASS
Le chargement a nécessité le package : mvtnorm
NOTE: THIS PACKAGE IS NOW OBSOLETE.
The R-Genetics project has developed an set of enhanced genetics
packages to replace 'genetics'. Please visit the project homepage
at http://rgenetics.org for informtion.
Attachement du package : ‘genetics’
Les objets suivants sont masqués from ‘package:base’:
as.factor, %in%, order
Le chargement a nécessité le package : ape
Attachement du package : ‘pegas’
L'objet suivant est masqué from ‘package:ape’:
mst
L'objet suivant est masqué from ‘package:genetics’:
haplotype
L'objet suivant est masqué from ‘package:ade4’:
amova
Converting data from a Genepop .gen file to a genind object...
File description: Id,
...done.
Converting data from a genind to a genpop object...
...done.
"),"pop"])) as.factor(as.character(colortab[which(colortab$PlantColor== "gold
> ls()
[1] "colorsAttribut" "colortab" "coordsAttribut" "dataSource" "fstats" "genpopData" "locis"
[8] "pops" "repool2"
> popf=pops
> pops
[1] 122GFCi119_02 230SCCi016_14 249SVCi030_22 319SMCi005_33
Levels: 122GFCi119_02 230SCCi016_14 249SVCi030_22 319SMCi005_33
> parpop <- seppop(datas,popf,drop=TRUE)
Erreur dans seppop(datas, popf, drop = TRUE) :
erreur d'évaluation de l'argument 'x' lors de la sélection d'une méthode pour la fonction 'seppop' : Erreur : objet 'datas' introuvable
> parpop <- seppop(dataSource,popf,drop=TRUE)
> parpop
$`122GFCi119_02`
#####################
### Genind object ###
#####################
- genotypes of individuals -
S4 class: genind
@call: .local(x = x, i = i, j = j, treatOther = ..1, quiet = ..2, drop = drop)
@tab: 172 x 157 matrix of genotypes
#####################
- genotypes of individuals -
S4 class: genind
@call: .local(x = x, i = i, j = j, treatOther = ..1, quiet = ..2, drop = drop)
@tab: 171 x 153 matrix of genotypes
@ind.names: vector of 171 individual names
@loc.names: vector of 24 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the 153 columns of @tab
@all.names: list of 24 components yielding allele names for each locus
@ploidy: 2
@type: codom
Optional contents:
@pop: factor giving the population of each individual
@pop.names: factor giving the population of each individual
@other: a list containing: elements without names
$`319SMCi005_33`
#####################
### Genind object ###
#####################
- genotypes of individuals -
S4 class: genind
@call: .local(x = x, i = i, j = j, treatOther = ..1, quiet = ..2, drop = drop)
@tab: 171 x 161 matrix of genotypes
@ind.names: vector of 171 individual names
@loc.names: vector of 24 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the 161 columns of @tab
@all.names: list of 24 components yielding allele names for each locus
@ploidy: 2
@type: codom
Optional contents:
@pop: factor giving the population of each individual
@pop.names: factor giving the population of each individual
@other: a list containing: elements without names
> length(parpop)
[1] 4
> length(unique(pop(dataSource)))
[1] 43
> repool3 <- function(listegenind){
+ start=TRUE
+ for( i in listegenind ){
+ if (start){ result= i; start=FALSE}
+ result <- repool(result,i)
+ }
+ return(result)
+ }
> repool3(parpop)
#####################
### Genind object ###
#####################
- genotypes of individuals -
S4 class: genind
@call: repool(result, i)
@tab: 857 x 194 matrix of genotypes
@ind.names: vector of 857 individual names
@loc.names: vector of 24 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the 194 columns of @tab
@all.names: list of 24 components yielding allele names for each locus
@ploidy: 2
@type: codom
Optional contents:
@pop: factor giving the population of each individual
@pop.names: factor giving the population of each individual
@other: - empty -
> dataSource
#####################
### Genind object ###
#####################
- genotypes of individuals -
S4 class: genind
@call: read.genepop(file = "~/analyseDep/0data/allpop3.gen")
@tab: 685 x 194 matrix of genotypes
@ind.names: vector of 685 individual names
@loc.names: vector of 24 locus names
@loc.nall: number of alleles per locus
@loc.fac: locus factor for the 194 columns of @tab
@all.names: list of 24 components yielding allele names for each locus
@ploidy: 2
@type: codom
Optional contents:
@pop: factor giving the population of each individual
@pop.names: factor giving the population of each individual
@other: - empty -
Retourner vers « Questions en cours »
Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 1 invité