This file contains hidden or 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
| cut -d ',' -f1 FDADOS_CENSO2014.csv|tail-n +2|sort|uniq -c|sort -nr |
This file contains hidden or 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
| # this a list in python,\n represents newline | |
| a = ['1', '2', '3', '4', '\n'] | |
| # convert list to string | |
| a = ''.join(a) | |
| # delete '\n' | |
| a = a.rstrip('\n') | |
| # convert string to integer | |
| a = map(int, a) | |
| # splitline | |
| a = ['1', '2', '3', '4', '\n', '5', '6', '7', '8'] |
This file contains hidden or 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
| a <- c(1:10) | |
| b <- c(1,3,5,11,12,13,14) | |
| c <- intersect(a, b) | |
| index.a <- match(c, a) # [1] 1 3 5 | |
| index.b <- match(c, b) # [1] 1 2 3 |
This file contains hidden or 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
| # convert charactor vector to a matrix | |
| a <- rep(NA, 2) # generate a vector | |
| a[1] <- '1, 2, 3, 4' | |
| a[2] <- '5, 6, 7, 8' | |
| a <- gsub('\\s', '', a) | |
| b <- matrix(NA, length(a), 4) | |
| for(i in 1:length(a)) { | |
| b[i, ] <- as.numeric(as.matrix(strsplit(a[i], ',')[[1]])) | |
| } |
This file contains hidden or 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
| ped = open('/data/bbl/bbl/bbl/ped/nnped.txt') | |
| try: | |
| peds = ped.readlines() | |
| finally: | |
| ped.close() | |
| outfile = open('/data/bbl/bbl/bbl/ped/pedxin.txt', 'w') | |
| for ped in peds: | |
| for i in range(0, 605997): | |
| this_snp = ped[i*4] + ped[i*4 + 1] + ped[i*4 + 2] | |
| outfile.write(this_snp + '\t') |