當前位置: 首頁>>代碼示例>>Python>>正文


Python PassingData.row_id2NA_mismatch_rate1方法代碼示例

本文整理匯總了Python中pymodule.PassingData.row_id2NA_mismatch_rate1方法的典型用法代碼示例。如果您正苦於以下問題:Python PassingData.row_id2NA_mismatch_rate1方法的具體用法?Python PassingData.row_id2NA_mismatch_rate1怎麽用?Python PassingData.row_id2NA_mismatch_rate1使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pymodule.PassingData的用法示例。


在下文中一共展示了PassingData.row_id2NA_mismatch_rate1方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: doFilter

# 需要導入模塊: from pymodule import PassingData [as 別名]
# 或者: from pymodule.PassingData import row_id2NA_mismatch_rate1 [as 別名]

#.........這裏部分代碼省略.........
                "max_snp_mismatch_rate_%s" % max_snp_mismatch_rate,
                "max_snp_NA_rate_%s" % max_snp_NA_rate,
                "npute_window_size_%s" % npute_window_size,
            ]
            output_fname = os.path.join(output_dir, "_".join(output_fname_prefix_ls + ["before_imputation.tsv"]))
            newSnpData.tofile(output_fname)
            # chromosomes = [snpsd_250k_tmp[i].chromosome for i in range(len(snpsd_250k_tmp))]
            # snpsdata.writeRawSnpsDatasToFile(output_fname, snpsd_250k_tmp, chromosomes=chromosomes, deliminator=',', withArrayIds = True)

        """
		qcdata.no_of_snps_filtered_by_mismatch = 0
		qcdata.no_of_snps_filtered_by_na = 0
		qcdata.no_of_monomorphic_snps_removed = 0
		for snpsd in snpsd_250k_tmp:
			qcdata.no_of_snps_filtered_by_mismatch += snpsd.no_of_snps_filtered_by_mismatch
			qcdata.no_of_snps_filtered_by_na += snpsd.no_of_snps_filtered_by_na
			qcdata.no_of_monomorphic_snps_removed += snpsd.no_of_monomorphic_snps_removed
		"""

        # snpData0 = RawSnpsData_ls2SNPData(snpsd_250k_tmp)

        twoSNPData0 = TwoSNPData(SNPData1=newSnpData, SNPData2=snpData_qc_strain, row_matching_by_which_value=0)
        row_id2NA_mismatch_rate0 = twoSNPData0.cmp_row_wise()
        col_id2NA_mismatch_rate0 = twoSNPData0.cmp_col_wise()
        del twoSNPData0

        result = []
        # for npute_window_size in npute_window_size_ls:
        # snpsd_250k_tmp_1 = copy.deepcopy(snpsd_250k_tmp)	#deepcopy, otherwise snpsd_250k_tmp_1[i].snps = [] would clear snpsd_250k_tmp up as well
        if len(newSnpData.row_id_ls) > 5:
            snps_name_ls = newSnpData.col_id_ls
            ## 2009-10-8 use NPUTE.samplingImpute()
            imputed_matrix, new_snps_name_ls = NPUTE.samplingImpute(
                snps_name_ls,
                newSnpData.data_matrix,
                input_file_format=1,
                input_NA_char=0,
                lower_case_for_imputation=False,
                npute_window_size=int(npute_window_size),
                no_of_accessions_per_sampling=300,
                coverage=3,
            )
            snpData_imputed = SNPData(
                row_id_ls=newSnpData.row_id_ls, col_id_ls=new_snps_name_ls, data_matrix=imputed_matrix
            )
            """
			## 2009-10-8 use NPUTE.samplingImpute() instead. comment out below
			chr2no_of_snps = NPUTE.get_chr2no_of_snps(snps_name_ls)
			chr_ls = chr2no_of_snps.keys()
			chr_ls.sort()
			snpData_imputed = SNPData(row_id_ls = newSnpData.row_id_ls, col_id_ls=[])
			matrix_ls = []
			for chromosome in chr_ls:
				if chr2no_of_snps[chromosome]>5:	#enough for imputation
					npute_data_struc = NPUTESNPData(snps_name_ls=snps_name_ls, data_matrix=newSnpData.data_matrix, chromosome=chromosome, \
									input_file_format=1, input_NA_char=0)
					imputeData(npute_data_struc, int(npute_window_size))
					matrix_ls.append(npute_data_struc.snps)
					snpData_imputed.col_id_ls += npute_data_struc.chosen_snps_name_ls
			if len(matrix_ls)>0:
				snpData_imputed.data_matrix = num.transpose(num.concatenate(matrix_ls))
			"""
            if output_dir:  # 2008-05-16 write the data out if output_fname is available
                # chromosomes = [snpsd_250k_tmp[i].chromosome for i in range(len(snpsd_250k_tmp))]	#already produced in the previous before_imputation output
                output_fname = os.path.join(output_dir, "_".join(output_fname_prefix_ls + ["after_imputation.tsv"]))
                # snpsdata.writeRawSnpsDatasToFile(output_fname, snpsd_250k_tmp, chromosomes=chromosomes, deliminator=',', withArrayIds = True)
                snpData_imputed.tofile(output_fname)

            twoSNPData1 = TwoSNPData(
                SNPData1=snpData_imputed, SNPData2=snpData_qc_strain, row_matching_by_which_value=0
            )
            qcdata.row_id2NA_mismatch_rate1 = twoSNPData1.cmp_row_wise()
            qcdata.col_id2NA_mismatch_rate1 = twoSNPData1.cmp_col_wise()
            del twoSNPData1, snpData_imputed
        else:
            snpData_imputed = None
            # qcdata.row_id2NA_mismatch_rate1 = {}
            # qcdata.col_id2NA_mismatch_rate1 = {}
        del newSnpData
        """
		for i in range(len(snpsd_250k_tmp)):
			#snpsd_250k_tmp_1[i].snps = []	#clear it up
			
			if len(snpsd_250k_tmp[i].accessions)>5 and len(snpsd_250k_tmp[i].positions)>5:	#not enough for imputation
				npute_data_struc = NPUTESNPData(inFile=snpsd_250k_tmp[i], input_NA_char='NA', input_file_format=4, lower_case_for_imputation=0)
				imputeData(npute_data_struc, int(npute_window_size))
				snpsd_250k_tmp[i].snps = npute_data_struc.snps
				del npute_data_struc
			"""
        qcdata.row_id2NA_mismatch_rate0 = row_id2NA_mismatch_rate0
        qcdata.col_id2NA_mismatch_rate0 = col_id2NA_mismatch_rate0

        qcdata.min_call_probability = min_call_probability
        qcdata.max_call_mismatch_rate = max_call_mismatch_rate
        qcdata.max_call_NA_rate = max_call_NA_rate
        qcdata.max_snp_mismatch_rate = max_snp_mismatch_rate
        qcdata.max_snp_NA_rate = max_snp_NA_rate
        qcdata.npute_window_size = npute_window_size
        result.append(qcdata)
        return result
開發者ID:,項目名稱:,代碼行數:104,代碼來源:


注:本文中的pymodule.PassingData.row_id2NA_mismatch_rate1方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。