美文网首页生物信息数据科学
82.《Bioinformatics Data Skills》之

82.《Bioinformatics Data Skills》之

作者: DataScience | 来源:发表于2021-12-20 19:30 被阅读0次

上节我们采用SELECT直接进行列信息提取,实际上可以在提取的同时创建与命名新的列。

以一个例子说明:

sqlite> SELECT lower(trait) AS trait,
   ...> "chr" || chrom || ":" || position AS region
   ...> FROM gwascat LIMIT 5;
trait                 region
--------------------  --------------
asthma and hay fever  chr6:32658824
asthma and hay fever  chr4:38798089
asthma and hay fever  chr5:111131801
asthma and hay fever  chr2:102350089
asthma and hay fever  chr17:39966427

其中第一句将trait列转为小写并命名为相同的名字trait;第二列通过||串连字符,创建“chr6:32658824”格式的输出并命名为region。

当某列信息存在NULL时,可以转为NA值,方便下游工具(如R)分析:

sqlite> SELECT ifnull(chrom, "NA") AS chrom , ifnull(position, "NA") AS position, strongest_risk_snp FROM gwascat WHERE strongest_risk_snp == "rs429358";
chrom  position  strongest_risk_snp
-----  --------  ------------------
19     44908684  rs429358
19     44908684  rs429358
NA     NA        rs429358

以上内容仅是皮毛作为例子,其它常用的SQLite函数包括:

SQLite 常用函数 SQLite 常用函数

相关文章

网友评论

    本文标题:82.《Bioinformatics Data Skills》之

    本文链接:https://www.haomeiwen.com/subject/ckizfrtx.html