我决定使用Pandas进行一些数据分析,并使用使用sqlite3语法的组合sqldf库。问题是我得到了一个非discript错误。我认为这是我的sql语法,但没有任何东西在我身上。
错误:
Error on sql SELECT u.chromosome, u.transcript_affected, u.ensembl_gene_id, u.gene_name ,u.strand, s.transcript_affected, s.ensembl_gene_id, s.gene_name FROM utr_file u INNER JOIN ssm_file s ON u.chromosome= s.chromosome AND u.strand = s.chromosome_strand WHERE s.chromosome_start BETWEEN u.start AND u.end ORDER BY u.chromosome;
SQL行(也在上面的错误中):
q = ''' SELECT u.chromosome, u.transcript_affected, u.ensembl_gene_id, u.gene_name ,u.strand, s.transcript_affected, s.ensembl_gene_id, s.gene_name FROM utr_file u INNER JOIN ssm_file s ON u.chromosome= s.chromosome AND u.strand = s.chromosome_strand WHERE s.chromosome_start BETWEEN u.start AND u.end ORDER BY u.chromosome;'''
qsubset= sqldf(q,globals())
目标: 我正在尝试确定str_file中的突变(按位置)在utr_file中的匹配(在开始和结束之间)。我还需要首先匹配染色体和链。
示例utr文件:
chromosome start end gene_name strand
0 chr1 67208778 67210768 NM_032291_utr3_24_0_chr1_67208779_f +
1 chr1 48998526 48999844 NM_032785_utr3_0_0_chr1_48998527_r -
2 chr1 16785385 16786584 NM_018090_utr3_7_0_chr1_16785386_f +
3 chr1 33585783 33585995 NM_052998_utr3_11_0_chr1_33585784_f +
4 chr1 16785385 16786584 NM_001145278_utr3_7_0_chr1_16785386_f +
示例ssm_file:
chromosome chromosome_start chromosome_strand transcript_affected \
0 chr1 100951090 + ENSG00000079335
1 chr1 100951090 + ENSG00000079335
2 chr1 100951090 + ENSG00000079335
3 chr1 100951090 + ENSG00000079335
4 chr1 100951090 + ENSG00000079335
ensembl_gene_id gene_name
0 ENST00000544534 CDC14A
1 ENST00000542213 CDC14A
2 ENST00000370125 CDC14A
3 ENST00000361544 CDC14A
4 ENST00000336454 CDC14A
答案 0 :(得分:2)
看起来您有一些列位置问题。我没有安装Pandas,但是这个查询适用于在sqlite中创建的临时表:
SELECT u.chromosome, u.gene_name ,u.strand, s.transcript_affected,
s.ensembl_gene_id, s.gene_name FROM utr_file u INNER JOIN ssm_file s ON u.chromosome=
s.chromosome AND u.strand = s.chromosome_strand
WHERE s.chromosome_start BETWEEN u.start AND u.end ORDER BY u.chromosome;
我从select中删除了u.ensembl_gene_id和u.transcript_affected,因为这些列只出现在ssm_file中。