Skip to content

help for fine mappting

1 message · PIKAL Petr

#
Hi Greg

Seems to me that spending some time with R tutorial would be way forward for you.

Something like that could work, but without some fake (but resembling real) data it is untested.

result <- data.frame(ss=rep(NA, nrow(ref)), ll= rep(NA, nrow(ref)), mm= rep(NA, nrow(ref)))

for (i in 1:nrow(ref)) {
sel <- map$ SNP_chr==ref$CHR & map$POS >= ref$POS_start[i] & map$POS < ref$POS_end[i]
result1 <- sum( map$post_prob[sel] )
result2 <- length( map$post_prob[sel] )
result3 <- min( map$p[sel] )
result[i, ] <-c(result1, result2, result3)
}

Cheers
Petr


From: greg holly [mailto:mak.hholly at gmail.com]
Sent: Thursday, June 16, 2016 10:04 PM
To: PIKAL Petr <petr.pikal at precheza.cz>
Subject: Re: [R] help for fine mappting

Hi Petr;

I got chance to try your codes. Once again thanks a lot. It seems the results3 is correct after I modified the "sel" as
sel <- map$ SNP_chr==ref$CHR & map$POS >= ref$POS_start[1] & map$POS < ref$POS_end[1] in the your codes:

sel <- map$POS >= ref$POS_start[1] & map$POS < ref$POS_end[1]
result1 <- sum( map$post_prob[sel] )
result2 <- length( map$post_prob[sel] )
result3 <- min( map$p[sel] )

and results3 is output of only the dirst row in "ref"file. I need results of other rows which I have 560 rows in "ref" file. I think I need a loop which more difficult part for me as I am beginner in R. In addition I need a output at the end as follow which has 560 rows.

All the best
Greg

structure(list(CHR = structure(1:2, .Label = c("chr1", "chr22"
), class = "factor"), POS = c(312127953L, 46487552L), POS_start = c(32036927L,
45766451L), POS_end = c(3232240262<tel:%283232240262>, 46801601), snp = structure(1:2, .Label = c("rs1143427",
"rs55958907"), class = "factor"), alle1l = structure(1:2, .Label = c("G",
"T"), class = "factor"), allel2 = structure(1:2, .Label = c("A",
"G"), class = "factor"), fr = c(0.278, 0.974), effec = c(0.6,
0.106), SE = c(0.015, 0.027), P = c(0.000156, 7.63e-05), post_prob = c(0.229,
0.125), n = c(612L, 4218L)), .Names = c("CHR", "POS", "POS_start",
"POS_end", "snp", "alle1l", "allel2", "fr", "effec", "SE", "P",
"post_prob", "n"), class = "data.frame", row.names = c(NA, -2L
))
On Thu, Jun 16, 2016 at 9:28 AM, PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote:
Hi

Did you test my suggestions? If not, why not? If yes, in what respect they did not work?

sel <- map$POS >= ref$POS_start[1] & map$POS < ref$POS_end[1]
result1 <- sum( map$post_prob[sel] )
result2 <- length( map$post_prob[sel] )
result3 <- min( map$p[sel] )

should give you desired values. It is up to you how do you want to organise them, as from your examples I do not have faintest idea what you want to do.

And keep your responds to r help list, I cc?d it.

Cheers
Petr

From: greg holly [mailto:mak.hholly at gmail.com<mailto:mak.hholly at gmail.com>]
Sent: Thursday, June 16, 2016 3:06 PM
To: PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>>
Subject: Re: [R] help for fine mappting

Hi PIKAL;

Thanks so much your writing. I am sorry if I could not explain precisely. All information in ref file are exist in map file. So they are in common. Ref file has about 560 and map file has 27 million rows.That is CHR column common in both and all value given ref$POS_start & ref$POS_end columns  are exist in map$POS.

Thanks in advance,

Greg
On Thu, Jun 16, 2016 at 3:16 AM, PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote:
Hi