I have a dataframe with a set of genomic co-ordinates. I wish to find genes around those co-ordinates using nearest.gene() which print result one at a time. I have been struggling to run the function in a loop:
apply(gene_lst, 1, function (x) nearest.gene(chr=gene_lst$Chr, pos=gene_lst$Pos))
1 2 3 4 5 6 7 8 9 10
"ACBD3" "ACBD3" "ACBD3" "ACBD3" "ACBD3" "ACBD3" "ACBD3" "ACBD3" "ACBD3" "ACBD3"
It is overwriting the first output for the next nine co-ordinates. Is there a better way to run this function?
applyfunction, you didn't passxinto your functionnearest.gene()