GEO处理总结

library(GEOquery)
library(limma)
gset <- getGEO('GSE76427', destdir=".",
               AnnotGPL = F,     ## 注释文件
               getGPL = F) 
a=gset[[1]]
dat1=exprs(a)
dim(dat1)

metadata=pData(a)

#转换ID#GPL3921	
library(hthgu133a.db)
ids=toTable(hthgu133aSYMBOL)
colnames(ids)=c('probe_id','symbol')  
ids=ids[ids$symbol != '',]
ids=ids[ids$probe_id %in%  rownames(dat1),]
dat1=dat1[ids$probe_id,] 
ids$median=apply(dat1,1,median) 
ids=ids[order(ids$symbol,ids$median,decreasing = T),]
ids=ids[!duplicated(ids$symbol),]
dat1=dat1[ids$probe_id,]
rownames(dat1)=ids$symbol
rt1 <- dat1
##GPL571
library(hgu133a2.db)
b=gset[[2]]
dat2=exprs(b)
id2=toTable(hgu133a2SYMBOL)
colnames(id2)=c('probe_id','symbol')  
id2=id2[id2$symbol != '',]
id2=id2[id2$probe_id %in%  rownames(dat2),]
dat2=dat2[id2$probe_id,] 
id2$median=apply(dat2,1,median) 
id2=id2[order(id2$symbol,id2$median,decreasing = T),]
id2=id2[!duplicated(id2$symbol),]
dat2=dat2[id2$probe_id,]
rownames(dat2)=id2$symbol
rt2 <- dat2
same <- intersect(row.names(rt2),row.names(rt1))
length(same)
rt <- cbind(rt2[same,],rt1[same,])

##标准化
boxplot(rt,las=2)
rt=normalizeBetweenArrays(rt)
boxplot(rt,las=2)
write.table(rt,file = 'GSE14520.txt',sep = '\t',quote = F)
###临床数据整理##
cli <- read.table('./00.data/03.GEO/GSE14520_Extra_Supplement.txt',sep = '\t',header = T,row.names = 1,check.names = F)
clinical <- cli[,c(1,8,9)]
table(clinical$`Tissue Type`)
clinical <- clinical[clinical$`Tissue Type`=='Tumor',]
clinical <- na.omit(clinical)
clinical$futime <- clinical$`Survival months`
clinical$fustat <- clinical$`Survival status`  
clinical <- clinical[,-c(1:3)]
clinical$futime <- clinical$futime/12
rt1 <- t(rt)
same1 <- intersect(row.names(clinical),row.names(rt1))
rt <- cbind(clinical[same1,],rt1[same1,])
save(rt,file = './00.data/03.GEO/GSE14520_input.RData')

### 使用 GeoTools 处理 KML 文件 GeoTools 是一个开源 Java 库,用于地理空间数据的处理。它支持多种地理空间数据格式,其中包括 KML (Keyhole Markup Language) 文件。以下是关于如何使用 GeoTools 进行 KML 文件的读取、解析以及写入的相关说明。 #### 依赖配置 为了能够使用 GeoTools 来操作 KML 文件,首先需要在项目中引入必要的 Maven 或 Gradle 依赖项: ```xml <!-- Maven --> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-main</artifactId> <version>27.0</version> <!-- 版本号可能有所不同,请根据实际需求调整 --> </dependency> <dependency> <groupId>org.geotools</groupId> <artifactId>gt-geojson</artifactId> <version>27.0</version> </dependency> <dependency> <groupId>org.geotools.xsd</groupId> <artifactId>gt-xsd-kml</artifactId> <version>27.0</version> </dependency> ``` 或者对于 Gradle 用户可以添加如下内容到 `build.gradle` 中: ```gradle implementation 'org.geotools:gt-main:27.0' implementation 'org.geotools:gt-geojson:27.0' implementation 'org.geotools.xsd:gt-xsd-kml:27.0' ``` --- #### 示例代码:读取 KML 文件 下面是一个简单的例子来展示如何通过 GeoTools 读取并解析 KML 文件的内容。 ```java import org.geotools.data.simple.SimpleFeatureCollection; import org.geotools.feature.FeatureIterator; import org.geotools.kml.KMLConfiguration; import org.geotools.xml.Parser; public class ReadKMLExample { public static void main(String[] args) throws Exception { File file = new File("path/to/your/file.kml"); // 替换为您的 KML 文件路径 Parser parser = new Parser(new KMLConfiguration()); Object featureCollectionElement = parser.parse(file); SimpleFeatureCollection features = (SimpleFeatureCollection) featureCollectionElement; try (FeatureIterator iterator = features.features()) { while (iterator.hasNext()) { System.out.println(iterator.next().toString()); // 输出每个要素的信息 } } catch (Exception e) { throw new RuntimeException(e); } } } ``` 此代码片段展示了如何加载 KML 文件,并将其转换成 `SimpleFeatureCollection` 对象以便进一步分析或可视化[^1]。 --- #### 示例代码:创建并保存新的 KML 文件 如果希望生成一个新的 KML 文件,则可以通过以下方式实现: ```java import org.geotools.factory.Hints; import org.geotools.geojson.feature.FeatureJSON; import org.geotools.geometry.jts.JTSFactoryFinder; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.GeometryFactory; import org.locationtech.jts.geom.Point; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; import java.io.FileWriter; import java.util.HashMap; import java.util.Map; public class WriteKMLExample { public static void main(String[] args) throws Exception { GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); Point point = geometryFactory.createPoint(new Coordinate(123, 45)); // 创建几何对象 Map<String, Class<?>> attributes = new HashMap<>(); attributes.put("name", String.class); // 定义属性字段及其类型 attributes.put("geometry", Point.class); SimpleFeatureType TYPE = DataUtilities.createType("Location", attributes.toString()); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(TYPE); builder.add("Sample Location"); builder.add(point); SimpleFeature feature = builder.buildFeature(null); FeatureJSON fJson = new FeatureJSON(); // 将特征序列化为 JSON/KML 格式 FileWriter writer = new FileWriter("output_file.kml"); fJson.setNamespace("http://www.opengis.net/kml/2.2"); // 设置命名空间 fJson.writeFeature(feature, writer); writer.close(); } } ``` 这段程序演示了如何构建一个包含单个点状位置的新 KML 文档,并将该文档保存至指定目录下[^2]。 --- #### 总结 以上介绍了利用 GeoTools 实现基本的 KML 数据读写功能的方法。需要注意的是,在实际应用过程中还需要考虑异常捕获机制以及其他边界条件等问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值