<font face="trebuchet ms,sans-serif">Saudações amigRos,<br><br>Estou com um problema que é o de identificar os indivíduos sem parentesco dentro de uma família. Basicamente ao construir a matriz de parentesco dos indivíduos eu gostaria de selecionar a submatriz desta que apresentasse valores iguais a zero fora da diagonal. Abaixo eu tenho o pedgree de duas famílias do qual, por meio da kinship2::kinship() eu obtenho a matriz de parentesco. Alguém teria alguma solução para o meu problema? Segue o CMR:<br>
<br><span style="font-family: courier new,monospace;"># dados</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">dados <- structure(list(FAMID = c(2L, 2L, 2L, 2L, 2L, 4L, 4L, 4L, 4L,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> ID = c(2101L, 2201L,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 2202L, 2302L, 2303L, 4101L, 4301L, 4302L, 4303L, 4501L, 4502L,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 4506L, 4601L, 4801L, 4802L, 4803L, 4806L, 4901L, 4902L, 4903L,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 4904L, 4905L, 4906L, 4907L, 4908L, 4909L, 4910L, 4911L, 4912L,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 4913L, 4914L, 4915L, 4916L, 4917L, 4918L, 4919L),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> FA = c(0L,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 0L, 0L, 2101L, 2101L, 4501L, 4201L, 4201L, 4201L, 4922L, 4921L,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 0L, 4501L, 4921L, 4921L, 4921L, 4922L, 4924L, 4924L, 4803L, 4806L,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 4806L, 4924L, 4806L, 4909L, 0L, 4924L, 0L, 4924L, 4924L, 4926L,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 4925L, 4918L, 4918L, 0L, 4806L),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> MO = c(0L, 0L, 0L, 2201L, 2201L,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 4502L, 4101L, 4101L, 4101L, 4923L, 4506L, 0L, 4502L, 4506L, 4506L,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 4506L, 4923L, 4911L, 4911L, 4910L, 4920L, 4920L, 4911L, 4920L,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 4801L, 0L, 4911L, 0L, 4911L, 4911L, 4906L, 4913L, 4908L, 4908L,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 0L, 4920L)),</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> .Names = c("FAMID", "ID", "FA", "MO"), class = "data.frame",</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> row.names = c(NA, -36L))</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># FAMID: id da familia</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># ID: id único de cada indivíduo</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># FA e MO: indica quem o pai(father) e mãe(mother) do indivíduo</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># valor 0 indica genitor desconhecido </span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># criando lista em que cada familia é um slot da lista</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">fam <- split(dados, dados$FAMID)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">str(fam)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">require(kinship2)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># obter a matriz de parentesco</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">m0 <- with(fam[[1]], kinship(ID, FA, MO))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">str(m0)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">m1 <- as.matrix(m0)</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># matriz de parentesco, verificar linhas/colunas de zeros, sem parentesco</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># objeto de desejo: indivíduos de uma família que tenham sub-matriz de parentesco</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># com elementos fora da diagonal iguais a zero</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># na m1 é a submatrix 3x3</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m1[1:3, 1:3]</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># os indivíduos são</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">rownames(m1[1:3, 1:3])</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m0 <- with(fam[[2]], kinship(ID, FA, MO))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">str(m0)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">m1 <- as.matrix(m0)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m1</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># essa matriz é enorme os não aparentados (no mínimo 4) não formam uma</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># submatriz agrupada</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># gostaria de ordenar essa matriz baseada nos elementos fora da diagonal</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># começando com os sem parentesco (parentesco=0), passando pelas</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># relações de primos/sobrinhos/netos (<0.25), e terminando com os</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># irmãos germanos (=0.25), seria possivel reordenar esse matriz assim?</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># uma forma de ordenar os não aparentados é deixar no início do pedgree</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># aqueles que tem genitor desconhecido</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">aux <- fam[[2]]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">aux <- aux[order(aux$FA, aux$MO),]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">head(aux)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m0 <- with(aux, kinship(ID, FA, MO))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">str(m0)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">m1 <- as.matrix(m0)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">m1[1:4, 1:4]</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># mas será que é garantido que indivíduos não aparentados só serão aqueles</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># que possuem genitor desconhecido no pedgree?</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># e se eu quisesse o sub-grupo de indivíduos em que nenhum parentesco exceda</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"># 0.05?</span><br style="font-family: courier new,monospace;"><br>Grato.<br>Walmes.<br><br><br clear="all"></font><span style="font-family: trebuchet ms,sans-serif;">==========================================================================</span><br style="font-family: trebuchet ms,sans-serif;">
<span style="font-family: trebuchet ms,sans-serif;">Walmes Marques Zeviani</span><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W)</span><br style="font-family: trebuchet ms,sans-serif;">
<span style="font-family: trebuchet ms,sans-serif;">Departamento de Estatística - Universidade Federal do Paraná</span><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">fone: (+55) 41 3361 3573</span><br style="font-family: trebuchet ms,sans-serif;">
<span style="font-family: trebuchet ms,sans-serif;">VoIP: (3361 3600) 1053 1173</span><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">e-mail: <a href="mailto:walmes@ufpr.br" target="_blank">walmes@ufpr.br</a></span><br style="font-family: trebuchet ms,sans-serif;">
<span style="font-family: trebuchet ms,sans-serif;">twitter: @walmeszeviani</span><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">homepage: <a href="http://www.leg.ufpr.br/%7Ewalmes" target="_blank">http://www.leg.ufpr.br/~walmes</a></span><br style="font-family: trebuchet ms,sans-serif;">
<span style="font-family: trebuchet ms,sans-serif;">linux user number: 531218</span><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">==========================================================================</span><br>