1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| f_infCNV_HMM_regions <- function(HMM_p, cB, s_f=T){ HMM_p <- HMM_p[HMM_p$state != 3, ] res <- HMM_p[c('cell_group_name','state', 'cnv_name')] res['cnv_name_s'] <- res['cnv_name'] for(i in 1:nrow(res)){ tmp <- with(HMM_p[i,], f_get_cytoBand_name(chr, start, end, cB)) tmp2 <- tmp[c(1,nrow(tmp)),] tmp <- paste0(tmp$V1,tmp$V4) tmp <- Reduce(x = tmp, f = function(x,y){paste0(x, '; ', y)}) res[i, 'cnv_name'] <- tmp tmp2 <- paste0(tmp2[1, 'V1'], tmp2[1, 'V4'], '-', tmp2[2, 'V4']) res[i, 'cnv_name_s'] <- tmp2 } res['state_d'] <- c('loss', 'loss', '1x', 'gain', 'gain', 'gain')[res$state] res['cnv_name_ss'] <- paste(res$cnv_name_s, res$state_d, sep = '_') if(s_f){ return(res) }else{ return(res[c('cell_group_name', 'cnv_name_ss')]) } }
|