Created
June 26, 2012 23:07
-
-
Save alexholehouse/2999989 to your computer and use it in GitHub Desktop.
CITPP correction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## The script [I'd edited] used to be; | |
#----------------------------------------- | |
cur.marker.id <- cbind(cur.marker.id, abs((cur.gene$startcoord+cur.gene$endcoord)/2 - cur.marker.id$chr_pos)) | |
names(cur.marker.id)[6] <- c("dis_from_cur_gene") | |
cur.marker.id <- which.min(cur.marker.id$dis_from_cur_gene) # cur.marker.id is now the row in the cur.marker.id matrix which represents the marker closest to the current gene | |
## having found the closes cna, we assign it's values to the cur.marker | |
cur.marker <- cna[,cur.marker.id] | |
#----------------------------------------- | |
## Which works for chromosome 1 because cur.marker.id ends up being a number from 1 to the number of chr1 markers. | |
## However, when we get to chromosome 2, cur.marker.id gets set to a number between 1 and number of chr2 markers, which still indexes into the cna[] array into | |
## chromosome 1 markers (there are fewer chr2 markers than chr1 markers). | |
## Easy fix is just; | |
#----------------------------------------- | |
cur.marker.id <- cbind(cur.marker.id, abs((cur.gene$startcoord+cur.gene$endcoord)/2 - cur.marker.id$chr_pos)) | |
names(cur.marker.id)[6] <-c("dis_from_cur_gene") | |
cur.marker.id <- cur.marker.id[which.min(cur.marker.id$dis_from_cur_gene), ] # so now we set cur.marker.id to the full vector containing all the info on the marker we want to select | |
## having found the closes cna, we assign it's values to the cur.marker | |
cur.marker <- cna[,cur.marker.id$marker_id] # we can pull the correct marker from cna via its $marker_id field, which is for this specific purpose! | |
----------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment